Comparing version 4.0.9 to 5.0.0
21
index.js
@@ -490,2 +490,14 @@ const WebTorrent = require('webtorrent') | ||
} | ||
let kindOfId | ||
if(this.checkAddress.test(id)){ | ||
kindOfId = 'address' | ||
} else if(this.checkHash.test(id)){ | ||
kindOfId = 'infohash' | ||
} else if(this.checkTitle.test(id)){ | ||
kindOfId = 'title' | ||
} else { | ||
throw new Error('id is not valid') | ||
} | ||
if(this.checkId.has(id)){ | ||
@@ -522,4 +534,8 @@ this.checkId.delete(id) | ||
} | ||
return {torrent: true, data: true} | ||
} else { | ||
const authorPath = path.join(this._author, id) | ||
if(!await fs.pathExists(authorPath)){ | ||
throw new Error('Must be creator to delete any files or directories inside the torrent') | ||
} | ||
const dataPath = path.join(folderPath, pathToData) | ||
@@ -529,4 +545,5 @@ if(await fs.pathExists(dataPath)){ | ||
} | ||
return {torrent: false, data: true} | ||
} | ||
return {id, path: pathToData, type: kindOfId} | ||
} | ||
@@ -533,0 +550,0 @@ // async publishHash(id, hash){ |
{ | ||
"name": "torrentz", | ||
"version": "4.0.9", | ||
"version": "5.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
31392
674