@tabcat/orbit-db-fsstore
Advanced tools
Comparing version 3.0.0 to 3.0.1
{ | ||
"name": "@tabcat/orbit-db-fsstore", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "a custom orbit-db store representing a file system", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -179,3 +179,5 @@ | ||
pathExistNo: (path) => new Error(`path '${path}' does not exist`), | ||
pathExistYes: (path) => new Error(`path '${path}' already exists`) | ||
pathExistYes: (path) => new Error(`path '${path}' already exists`), | ||
pathDirNo: (path) => new Error(`path '${path}' is not a dir`), | ||
pathFileNo: (path) => new Error(`path '${path}' is not a file`) | ||
} | ||
@@ -182,0 +184,0 @@ |
@@ -16,9 +16,14 @@ | ||
const cTypeError = (cType) => cType === fs.cTypes.dir | ||
? errors.pathDirNo | ||
: errors.pathFileNo | ||
const paramChecks = (self) => ({ | ||
path: ({ path }) => { | ||
path: ({ path }, cType) => { | ||
if (!pathValid(path)) throw errors.pathValidNo(path) | ||
if (!self.exists(path)) throw errors.pathExistNo(path) | ||
if (self.content(path) !== cType) throw cTypeError(cType)(path) | ||
return true | ||
}, | ||
pathName: ({ path, name }) => { | ||
pathName: ({ path, name }, cType) => { | ||
if (!pathValid(path)) throw errors.pathValidNo(path) | ||
@@ -28,5 +33,6 @@ if (!nameValid(name)) throw errors.nameValidNo(name) | ||
if (self.exists(joinPath(path, name))) throw errors.pathExistYes(joinPath(path, name)) | ||
if (self.content(path) !== fs.cTypes.dir) throw errors.pathDirNo(path) | ||
return true | ||
}, | ||
pathDestName: ({ path, dest, name }) => { | ||
pathDestName: ({ path, dest, name }, cType) => { | ||
if (!pathValid(path)) throw errors.pathValidNo(path) | ||
@@ -38,2 +44,4 @@ if (!pathValid(dest)) throw errors.pathValidNo(dest) | ||
if (self.exists(joinPath(dest, name))) throw errors.pathExistYes(joinPath(dest, name)) | ||
if (self.content(path) !== cType) throw cTypeError(cType)(path) | ||
if (self.content(dest) !== fs.cTypes.dir) throw errors.pathDirNo(dest) | ||
return true | ||
@@ -79,3 +87,4 @@ }, | ||
_addOp ({ op, ...payload }) { | ||
this.paramChecks[paramKeys[op]](payload) | ||
const cType = op.slice(-3) === 'DIR' ? fs.cTypes.dir : fs.cTypes.file | ||
this.paramChecks[paramKeys[op]](payload, cType) | ||
return this._addOperation({ op, ...payload }) | ||
@@ -82,0 +91,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
16144
337