pathchain 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/maker.js +9 -9
- package/package.json +1 -1
- package/updater.js +8 -4
package/maker.js
CHANGED
|
@@ -245,7 +245,7 @@ function path(text, elements, author, ancestor, format = 'MM DD YYYY HH:mm:SSS [
|
|
|
245
245
|
register: `moments/${register_moment_hash}`,
|
|
246
246
|
author: author,
|
|
247
247
|
text: text,
|
|
248
|
-
head:
|
|
248
|
+
head: `${prev_link}`,
|
|
249
249
|
ancestor: `${author_folder}paths/${ancestor}`,
|
|
250
250
|
tag: `${author_folder}paths/${path_hash}`,
|
|
251
251
|
});
|
|
@@ -349,6 +349,11 @@ function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:S
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
+
// Checking target existance
|
|
353
|
+
if (!checker.checkFile(`files/${target}`)) {
|
|
354
|
+
return "Target was not found!";
|
|
355
|
+
}
|
|
356
|
+
|
|
352
357
|
// Homogenize the author.
|
|
353
358
|
// Break down the target address
|
|
354
359
|
// Make a copy of it inside *author* address if it is not public or if the original author is different than *author*
|
|
@@ -358,18 +363,13 @@ function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:S
|
|
|
358
363
|
const register = dt.format(new Date(), dt.compile(format, true));
|
|
359
364
|
const register_moment_hash = moment(register, 0, 0, 0, 0, 0, format);
|
|
360
365
|
|
|
361
|
-
|
|
366
|
+
// Generate a unique hash for this link
|
|
367
|
+
const link_hash = sha256(`${register_moment_hash}_${author}_${prev}_${next}`);
|
|
368
|
+
|
|
362
369
|
// Set default values if not provided
|
|
363
370
|
if (ancestor === "") { ancestor = link_hash; }
|
|
364
371
|
if (prev === "") { prev = link_hash; }
|
|
365
372
|
if (next === "") { next = link_hash; }
|
|
366
|
-
|
|
367
|
-
// Generate a unique hash for this link
|
|
368
|
-
const link_hash = sha256(`${register_moment_hash}_${author}_${prev}_${next}`);
|
|
369
|
-
|
|
370
|
-
if (!checker.checkFile(`files/${target}`)) {
|
|
371
|
-
return "Target was not found!";
|
|
372
|
-
}
|
|
373
373
|
|
|
374
374
|
// Encode the link data into a protocol buffer
|
|
375
375
|
const buffer = link_pb.link.encode({
|
package/package.json
CHANGED
package/updater.js
CHANGED
|
@@ -58,6 +58,8 @@ function useSecret(xsecret, xauthor = "") {
|
|
|
58
58
|
* @return {string} xlink
|
|
59
59
|
*/
|
|
60
60
|
function setLinkNext(xlink = "", xnextlink = "") {
|
|
61
|
+
console.log("Setting link: ", xnextlink);
|
|
62
|
+
console.log("As prev link for: ", xlink);
|
|
61
63
|
|
|
62
64
|
// LOADING PB
|
|
63
65
|
var link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'))
|
|
@@ -67,7 +69,7 @@ function setLinkNext(xlink = "", xnextlink = "") {
|
|
|
67
69
|
|
|
68
70
|
// NOT FOUND EXCEPTION FOR 'xlink'
|
|
69
71
|
try {
|
|
70
|
-
fileContents = fs.readFileSync("files/
|
|
72
|
+
fileContents = fs.readFileSync("files/" + xlink);
|
|
71
73
|
} catch (err) {
|
|
72
74
|
if (err.code === 'ENOENT') {
|
|
73
75
|
return "Link '" + xlink + "' not found";
|
|
@@ -78,7 +80,7 @@ function setLinkNext(xlink = "", xnextlink = "") {
|
|
|
78
80
|
|
|
79
81
|
// NOT FOUND EXCEPTION FOR 'xnextlink'
|
|
80
82
|
try {
|
|
81
|
-
fileContents = fs.readFileSync("files/
|
|
83
|
+
fileContents = fs.readFileSync("files/" + xnextlink);
|
|
82
84
|
} catch (err) {
|
|
83
85
|
if (err.code === 'ENOENT') {
|
|
84
86
|
return "Link '" + xnextlink + "' not found";
|
|
@@ -105,6 +107,8 @@ function setLinkNext(xlink = "", xnextlink = "") {
|
|
|
105
107
|
* @return {string} xlink
|
|
106
108
|
*/
|
|
107
109
|
function setLinkPrev(xlink = "", xprevlink = "") {
|
|
110
|
+
console.log("Setting link: ", xprevlink);
|
|
111
|
+
console.log("As prev link for: ", xlink);
|
|
108
112
|
|
|
109
113
|
// LOADING PB
|
|
110
114
|
var link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'))
|
|
@@ -114,7 +118,7 @@ function setLinkPrev(xlink = "", xprevlink = "") {
|
|
|
114
118
|
|
|
115
119
|
// NOT FOUND EXCEPTION FOR 'xlink'
|
|
116
120
|
try {
|
|
117
|
-
fileContents = fs.readFileSync("files/
|
|
121
|
+
fileContents = fs.readFileSync("files/" + xlink);
|
|
118
122
|
} catch (err) {
|
|
119
123
|
if (err.code === 'ENOENT') {
|
|
120
124
|
return "Link '" + xlink + "' not found";
|
|
@@ -125,7 +129,7 @@ function setLinkPrev(xlink = "", xprevlink = "") {
|
|
|
125
129
|
|
|
126
130
|
// NOT FOUND EXCEPTION FOR 'xprevlink'
|
|
127
131
|
try {
|
|
128
|
-
fileContents = fs.readFileSync("files/
|
|
132
|
+
fileContents = fs.readFileSync("files/" + xprevlink);
|
|
129
133
|
} catch (err) {
|
|
130
134
|
if (err.code === 'ENOENT') {
|
|
131
135
|
return "Link '" + xprevlink + "' not found";
|