mirror of
https://github.com/zoriya/flood.git
synced 2025-12-20 22:25:16 +00:00
Ensure that only files belonging to torrent are deleted
This commit is contained in:
@@ -10,7 +10,6 @@ const clientResponseUtil = require('../util/clientResponseUtil');
|
||||
const clientSettingsMap = require('../../shared/constants/clientSettingsMap');
|
||||
const ClientRequest = require('./ClientRequest');
|
||||
const formatUtil = require('../../shared/util/formatUtil');
|
||||
const scgi = require('../util/scgi');
|
||||
const TemporaryStorage = require('./TemporaryStorage');
|
||||
const torrentFilePropsMap = require('../../shared/constants/torrentFilePropsMap');
|
||||
const torrentPeerPropsMap = require('../../shared/constants/torrentPeerPropsMap');
|
||||
@@ -78,43 +77,6 @@ var client = {
|
||||
request.send();
|
||||
},
|
||||
|
||||
deleteTorrents: (options, callback) => {
|
||||
let filesToDelete = null;
|
||||
let eraseTorrentsRequest = new ClientRequest();
|
||||
|
||||
eraseTorrentsRequest.removeTorrents({hashes: options.hashes});
|
||||
eraseTorrentsRequest.onComplete((response, error) => {
|
||||
if (options.deleteData) {
|
||||
const torrents = torrentCollection.torrents;
|
||||
|
||||
options.hashes.forEach(hash => {
|
||||
let fileToDelete = null;
|
||||
const torrent = torrents[hash];
|
||||
|
||||
if (torrent.isMultiFile && torrent.directory != null) {
|
||||
fileToDelete = torrent.directory;
|
||||
} else if (torrent.directory != null && torrent.name != null) {
|
||||
fileToDelete = path.join(torrent.directory, torrent.name);
|
||||
}
|
||||
|
||||
if (fileToDelete != null) {
|
||||
rimraf(fileToDelete, {disableGlob: true}, error => {
|
||||
if (error) {
|
||||
console.error(`Error deleting file: ${fileToDelete}\n${error}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
torrentService.fetchTorrentList();
|
||||
|
||||
callback(response, error);
|
||||
});
|
||||
|
||||
eraseTorrentsRequest.send();
|
||||
},
|
||||
|
||||
downloadFiles(hash, files, res) {
|
||||
try {
|
||||
let selectedTorrent = null;
|
||||
|
||||
Reference in New Issue
Block a user