@cypsela/sailplane-node
Advanced tools
Comparing version
{ | ||
"name": "@cypsela/sailplane-node", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "collaborative file system on ipfs", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -39,5 +39,5 @@ | ||
// improvement: remove uncalled, queued promises on add of new promise | ||
this._updateQueue = new PQueue() | ||
this._onDbUpdate = () => this._updateQueue.add(() => this._getCid()) | ||
this._updateQueue = new PQueue({ concurrency: 1 }) | ||
this._onDbUpdate = () => | ||
this._updateQueue.size === 0 && this._updateQueue.add(() => this._getCid()) | ||
@@ -136,4 +136,15 @@ this.running = null | ||
function useCidClass (CID) { | ||
return function validCid (cid) { | ||
try { | ||
return !!new CID(cid) | ||
} catch (e) { | ||
return false | ||
} | ||
} | ||
} | ||
async function * ipfsTree (path) { | ||
const emptyFile = await last(this._ipfs.add('')) | ||
const validCid = useCidClass(emptyFile.cid.constructor) | ||
const fsStruct = [path, ...this.fs.tree(path)] | ||
@@ -143,3 +154,6 @@ .map((p) => ({ | ||
content: this.fs.content(p) === 'file' | ||
? this._ipfs.cat(this.fs.read(p) || emptyFile.cid) | ||
? this._ipfs.cat( | ||
(validCid(this.fs.read(p)) && this.fs.read(p)) || | ||
emptyFile.cid | ||
) | ||
: undefined | ||
@@ -146,0 +160,0 @@ })) |
12933
2.41%186
7.51%