@cypsela/sailplane-node
Advanced tools
Comparing version 2.0.0 to 2.1.0
{ | ||
"name": "@cypsela/sailplane-node", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "collaborative file system on ipfs", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -12,5 +12,3 @@ | ||
pathExistNo: (path) => new Error(`path '${path}' does not exist`), | ||
pathExistYes: (path) => new Error(`path '${path}' already exists`), | ||
pathDirNo: (path) => new Error(`path '${path}' is not a directory`), | ||
pathFileNo: (path) => new Error(`path '${path}' is not a file`) | ||
pathDirNo: (path) => new Error(`path '${path}' is not a directory`) | ||
} | ||
@@ -106,3 +104,3 @@ | ||
async upload (path, source) { | ||
async upload (path, source, options = {}) { | ||
if (this.fs.content(path) !== 'dir') throw errors.pathDirNo(path) | ||
@@ -114,3 +112,3 @@ | ||
try { | ||
const ipfsUpload = await all(this._ipfs.add(source, ipfsAddConfig)) | ||
const ipfsUpload = await all(this._ipfs.add(source, ipfsAddConfig, options)) | ||
const batch = this._db.batch() | ||
@@ -155,6 +153,2 @@ | ||
async mkdir (path, name) { | ||
if (!this.fs.exists(path)) throw errors.pathExistNo(path) | ||
if (this.fs.exists(this.fs.joinPath(path, name))) { | ||
throw errors.pathExistYes(this.fs.joinPath(path, name)) | ||
} | ||
await this._db.mkdir(path, name) | ||
@@ -165,6 +159,2 @@ this.events.emit('mkdir') | ||
async mkfile (path, name) { | ||
if (!this.fs.exists(path)) throw errors.pathExistNo(path) | ||
if (this.fs.exists(this.fs.joinPath(path, name))) { | ||
throw errors.pathExistYes(this.fs.joinPath(path, name)) | ||
} | ||
await this._db.mk(path, name) | ||
@@ -175,4 +165,2 @@ this.events.emit('mkfile') | ||
async write (path, cid) { | ||
if (!this.fs.exists(path)) throw errors.pathExistNo(path) | ||
if (this.fs.content(path) !== 'file') throw errors.pathFileNo(path) | ||
if (!validCid(this._CID, cid)) throw new Error('invalid cid') | ||
@@ -184,3 +172,2 @@ await this._db.write(path, cid.toString()) | ||
async read (path) { | ||
if (!this.fs.exists(path)) throw errors.pathExistNo(path) | ||
return this._getCid(path) | ||
@@ -187,0 +174,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15997
247