mirror of
https://github.com/zoriya/flood.git
synced 2026-06-02 11:06:35 +00:00
Don't use base_path property when deleting files
This commit is contained in:
@@ -66,6 +66,18 @@ class Torrent {
|
||||
return Object.assign({}, this.torrentData);
|
||||
}
|
||||
|
||||
get directory() {
|
||||
return this.torrentData.directory;
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this.torrentData.name;
|
||||
}
|
||||
|
||||
get isMultiFile() {
|
||||
return this.torrentData.isMultiFile === '1';
|
||||
}
|
||||
|
||||
get status() {
|
||||
return this.torrentData.status || [];
|
||||
}
|
||||
|
||||
+16
-15
@@ -87,36 +87,37 @@ var client = {
|
||||
},
|
||||
|
||||
deleteTorrents: (options, callback) => {
|
||||
let files = [];
|
||||
let request = new ClientRequest();
|
||||
let filesToDelete = null;
|
||||
let eraseTorrentsRequest = new ClientRequest();
|
||||
|
||||
if (options.deleteData) {
|
||||
let torrents = torrentCollection.torrents;
|
||||
const torrents = torrentCollection.torrents;
|
||||
|
||||
files = options.hashes.reduce((memo, hash) => {
|
||||
let filePath = torrents[hash].basePath;
|
||||
filesToDelete = options.hashes.reduce((accumulator, hash) => {
|
||||
const torrent = torrents[hash];
|
||||
|
||||
// Let's not try to delete these files.
|
||||
if (filePath != null && filePath !== '/' && filePath !== ''
|
||||
&& filePath !== '.') {
|
||||
memo.push(filePath);
|
||||
if (torrent.isMultiFile && torrent.directory != null) {
|
||||
accumulator.push(torrent.directory);
|
||||
} else if (torrent.directory != null && torrent.name != null) {
|
||||
accumulator.push(path.join(torrent.directory, torrent.name));
|
||||
}
|
||||
|
||||
return memo;
|
||||
return accumulator;
|
||||
}, []);
|
||||
}
|
||||
|
||||
request.removeTorrents({hashes: options.hashes});
|
||||
request.onComplete((response, error) => {
|
||||
if (options.deleteData && files.length > 0) {
|
||||
del(files, {force: true});
|
||||
eraseTorrentsRequest.removeTorrents({hashes: options.hashes});
|
||||
eraseTorrentsRequest.onComplete((response, error) => {
|
||||
if (options.deleteData && filesToDelete.length > 0) {
|
||||
del(filesToDelete, {force: true});
|
||||
}
|
||||
|
||||
client.updateTorrentList();
|
||||
|
||||
callback(response, error);
|
||||
});
|
||||
request.send();
|
||||
|
||||
eraseTorrentsRequest.send();
|
||||
},
|
||||
|
||||
downloadFiles(hash, files, res) {
|
||||
|
||||
Reference in New Issue
Block a user