Comparing version 2.0.1 to 2.0.2
41
index.js
@@ -178,3 +178,3 @@ const WebTorrent = require('webtorrent') | ||
} else { | ||
seq = count === null ? 0 : count | ||
seq = count ? count : 0 | ||
} | ||
@@ -329,6 +329,6 @@ | ||
} | ||
async publishTorrent(update, id, count, headers, data, checkTimeout = 0, empty = null){ | ||
async publishTorrent(gen, id, count, headers, data, checkTimeout = 0, empty = null){ | ||
const useTimeout = checkTimeout ? checkTimeout : this._timeout | ||
if(update){ | ||
if (!id || !id.address || !id.secret) { | ||
if(gen){ | ||
if (!id.address || !id.secret) { | ||
id = this.createKeypair() | ||
@@ -399,25 +399,6 @@ } else { | ||
if(id.sub){ | ||
if(this.checkId.has(id.sub)){ | ||
this.checkId.delete(id.sub) | ||
} | ||
const subTorrent = this.findTheTorrent(id.sub) | ||
if(subTorrent){ | ||
await new Promise((resolve, reject) => { | ||
this.webtorrent.remove(subTorrent.infoHash, {destroyStore: false}, error => { | ||
if(error){ | ||
reject(error) | ||
} else { | ||
resolve() | ||
} | ||
}) | ||
}) | ||
} | ||
await fs.remove(path.join(this._storage, id.sub)) | ||
if(this.checkId.has(id)){ | ||
this.checkId.delete(id) | ||
} | ||
if(this.checkId.has(id.title)){ | ||
this.checkId.delete(id.title) | ||
} | ||
const activeTorrent = this.findTheTorrent(id.title) | ||
const activeTorrent = this.findTheTorrent(id) | ||
if(activeTorrent){ | ||
@@ -434,4 +415,4 @@ await new Promise((resolve, reject) => { | ||
} | ||
const folderPath = path.join(this._storage, id.title) | ||
const authorPath = path.join(this._author, id.title) | ||
const folderPath = path.join(this._storage, id) | ||
const authorPath = path.join(this._author, id) | ||
if(empty){ | ||
@@ -465,3 +446,3 @@ await fs.emptyDir(folderPath) | ||
checkTorrent.folder = folderPath | ||
checkTorrent.title = id.title | ||
checkTorrent.title = id | ||
checkTorrent.address = null | ||
@@ -472,3 +453,3 @@ checkTorrent.own = true | ||
await fs.writeFile(authorPath, checkTorrent.infohash) | ||
this.checkId.set(id.title, checkTorrent) | ||
this.checkId.set(id, checkTorrent) | ||
return { torrent: checkTorrent, infohash: checkTorrent.infohash, title: checkTorrent.title } | ||
@@ -475,0 +456,0 @@ } |
{ | ||
"name": "torrentz", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"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
25481
601