pathchain 1.1.25 → 1.1.26

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/updater.js +7 -29
package/package.json CHANGED
@@ -34,5 +34,5 @@
34
34
  "deprecated": false,
35
35
  "description": "![image](https://user-images.githubusercontent.com/104391124/282268780-cbbc1ee6-8d97-4d80-b896-66ae3eb723dd.png)",
36
36
  "name": "pathchain",
37
- "version": "1.1.25"
37
+ "version": "1.1.26"
38
38
  }
package/updater.js CHANGED
@@ -51,21 +51,13 @@ function setLinkNext(xlink = '', xnextlink = '') {
51
51
 
52
52
  const fileContents = fs.readFileSync(`files/${xlink}`);
53
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
- });
54
+ linkObj.next = xnextlink;
55
+ fs.writeFileSync(`files/${xlink}`, link_pb.link.encode(linkObj));
56
+
65
57
 
66
58
  // Ensure the directory exists and overwrite the link buffer to a file
67
- checker.checkDir(`files/${xlink}`);
68
- fs.writeFileSync(`files/${xlink}`, buffer);
59
+ // checker.checkDir(`files/${xlink}`);
60
+ // fs.writeFileSync(`files/${xlink}`, buffer);
69
61
 
70
62
  return xlink;
71
63
  } catch (err) {
@@ -86,27 +78,13 @@ function setLinkPrev(xlink = '', xprevlink = '') {
86
78
  const link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'));
87
79
 
88
80
  try {
89
- // Check if both links exist
90
81
  fs.readFileSync(`files/${xlink}`);
91
82
  fs.readFileSync(`files/${xprevlink}`);
92
83
 
93
84
  const fileContents = fs.readFileSync(`files/${xlink}`);
94
85
  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);
86
+ linkObj.prev = xprevlink;
87
+ fs.writeFileSync(`files/${xlink}`, link_pb.link.encode(linkObj));
110
88
 
111
89
  return xlink;
112
90