pathchain 1.1.23 → 1.1.25
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 +1 -1
- package/package.json +1 -1
- package/updater.js +38 -9
package/maker.js
CHANGED
|
@@ -235,7 +235,7 @@ function path(text, elements, author, ancestor, format = 'MM DD YYYY HH:mm:SSS [
|
|
|
235
235
|
for (let i = 0; i < elements.length; i++) {
|
|
236
236
|
// link with no next and no prev is set with its target as the current element
|
|
237
237
|
const current_link = link(elements[i], "", "", author, "");
|
|
238
|
-
//
|
|
238
|
+
// only if this is not the first element
|
|
239
239
|
if (i > 0) {
|
|
240
240
|
updater.setLinkNext(prev_link, current_link);
|
|
241
241
|
updater.setLinkPrev(current_link, prev_link);
|
package/package.json
CHANGED
package/updater.js
CHANGED
|
@@ -42,7 +42,7 @@ function setLinkNext(xlink = '', xnextlink = '') {
|
|
|
42
42
|
console.log('Setting link:', xnextlink);
|
|
43
43
|
console.log('As NEXT link for:', xlink);
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'));
|
|
46
46
|
|
|
47
47
|
try {
|
|
48
48
|
// Check if both links exist
|
|
@@ -50,10 +50,24 @@ function setLinkNext(xlink = '', xnextlink = '') {
|
|
|
50
50
|
fs.readFileSync(`files/${xnextlink}`);
|
|
51
51
|
|
|
52
52
|
const fileContents = fs.readFileSync(`files/${xlink}`);
|
|
53
|
-
const linkObj =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const linkObj = link_pb.link.decode(fileContents);
|
|
54
|
+
|
|
55
|
+
// Encode the link data into a protocol buffer
|
|
56
|
+
const buffer = link_pb.link.encode({
|
|
57
|
+
register: linkObj.register,
|
|
58
|
+
author: linkObj.author,
|
|
59
|
+
prev: xnextlink,
|
|
60
|
+
next: linkObj.next,
|
|
61
|
+
target: linkObj.target,
|
|
62
|
+
ancestor: linkObj.ancestor,
|
|
63
|
+
tag: linkObj.tag
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Ensure the directory exists and overwrite the link buffer to a file
|
|
67
|
+
checker.checkDir(`files/${xlink}`);
|
|
68
|
+
fs.writeFileSync(`files/${xlink}`, buffer);
|
|
69
|
+
|
|
70
|
+
return xlink;
|
|
57
71
|
} catch (err) {
|
|
58
72
|
return err.code === 'ENOENT' ? `Link '${err.path.split('/').pop()}' not found` : err;
|
|
59
73
|
}
|
|
@@ -69,7 +83,7 @@ function setLinkPrev(xlink = '', xprevlink = '') {
|
|
|
69
83
|
console.log('Setting link:', xprevlink);
|
|
70
84
|
console.log('As PREV link for:', xlink);
|
|
71
85
|
|
|
72
|
-
const
|
|
86
|
+
const link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'));
|
|
73
87
|
|
|
74
88
|
try {
|
|
75
89
|
// Check if both links exist
|
|
@@ -77,10 +91,25 @@ function setLinkPrev(xlink = '', xprevlink = '') {
|
|
|
77
91
|
fs.readFileSync(`files/${xprevlink}`);
|
|
78
92
|
|
|
79
93
|
const fileContents = fs.readFileSync(`files/${xlink}`);
|
|
80
|
-
const linkObj =
|
|
81
|
-
|
|
94
|
+
const linkObj = link_pb.link.decode(fileContents);
|
|
95
|
+
|
|
96
|
+
// Encode the link data into a protocol buffer
|
|
97
|
+
const buffer = link_pb.link.encode({
|
|
98
|
+
register: linkObj.register,
|
|
99
|
+
author: linkObj.author,
|
|
100
|
+
prev: xprevlink,
|
|
101
|
+
next: linkObj.next,
|
|
102
|
+
target: linkObj.target,
|
|
103
|
+
ancestor: linkObj.ancestor,
|
|
104
|
+
tag: linkObj.tag
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Ensure the directory exists and overwrite the link buffer to a file
|
|
108
|
+
checker.checkDir(`files/${xlink}`);
|
|
109
|
+
fs.writeFileSync(`files/${xlink}`, buffer);
|
|
110
|
+
|
|
111
|
+
return xlink;
|
|
82
112
|
|
|
83
|
-
return linkObj;
|
|
84
113
|
} catch (err) {
|
|
85
114
|
return err.code === 'ENOENT' ? `Link '${err.path.split('/').pop()}' not found` : err;
|
|
86
115
|
}
|