pathchain 1.1.23 → 1.1.24
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/package.json +1 -1
- package/updater.js +38 -9
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(xlink);
|
|
68
|
+
fs.writeFileSync(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(xlink);
|
|
109
|
+
fs.writeFileSync(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
|
}
|