mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-10 07:50:29 -07:00
Only delete if rename succeeds
This commit is contained in:
parent
7d3b4f3bd7
commit
cf1b27c26d
2 changed files with 13 additions and 12 deletions
|
|
@ -95,15 +95,15 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|||
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
// delete original file
|
||||
if (fs.existsSync(args.originalLibraryFile._id)) {
|
||||
fs.unlinkSync(args.originalLibraryFile._id);
|
||||
}
|
||||
// delete temp file
|
||||
if (fs.existsSync(newPath)) {
|
||||
fs.unlinkSync(newPath);
|
||||
}
|
||||
fs.renameSync(currentPath, newPathTmp);
|
||||
// delete original file
|
||||
if (fs.existsSync(args.originalLibraryFile._id)) {
|
||||
fs.unlinkSync(args.originalLibraryFile._id);
|
||||
}
|
||||
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
||||
case 2:
|
||||
_a.sent();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue