MCPcopy
hub / github.com/entropic-dev/entropic / add

Method add

services/storage/lib/object-storage.js:97–117  ·  view source on GitHub ↗
(algo, digest, data)

Source from the content-addressed store, hash-verified

95 }
96
97 async add(algo, digest, data) {
98 digest = encodeURIComponent(digest);
99 if (!this.algos.has(algo)) {
100 await mkdirp(`${this.dir}/${algo}/tmp`);
101 this.algos.add(algo);
102 }
103
104 const uniq = uuid.v4();
105 await fs.writeFile(`${this.dir}/${algo}/tmp/${uniq}`, data);
106 try {
107 await fs.link(
108 `${this.dir}/${algo}/tmp/${uniq}`,
109 `${this.dir}/${algo}/${digest}`
110 );
111 } catch (err) {
112 if (err.code !== 'EEXIST') {
113 throw err;
114 }
115 }
116 await fs.unlink(`${this.dir}/${algo}/tmp/${uniq}`);
117 }
118 };
119};

Callers

nothing calls this directly

Calls 2

hasMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected