mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-17 11:16:26 -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); })];
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
||||||
case 1:
|
case 1:
|
||||||
_a.sent();
|
_a.sent();
|
||||||
// delete original file
|
|
||||||
if (fs.existsSync(args.originalLibraryFile._id)) {
|
|
||||||
fs.unlinkSync(args.originalLibraryFile._id);
|
|
||||||
}
|
|
||||||
// delete temp file
|
// delete temp file
|
||||||
if (fs.existsSync(newPath)) {
|
if (fs.existsSync(newPath)) {
|
||||||
fs.unlinkSync(newPath);
|
fs.unlinkSync(newPath);
|
||||||
}
|
}
|
||||||
fs.renameSync(currentPath, newPathTmp);
|
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); })];
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
||||||
case 2:
|
case 2:
|
||||||
_a.sent();
|
_a.sent();
|
||||||
|
|
|
||||||
|
|
@ -67,17 +67,18 @@ const plugin = async (args:IpluginInputArgs):Promise<IpluginOutputArgs> => {
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
|
|
||||||
// delete original file
|
|
||||||
if (fs.existsSync(args.originalLibraryFile._id)) {
|
|
||||||
fs.unlinkSync(args.originalLibraryFile._id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete temp file
|
// delete temp file
|
||||||
if (fs.existsSync(newPath)) {
|
if (fs.existsSync(newPath)) {
|
||||||
fs.unlinkSync(newPath);
|
fs.unlinkSync(newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.renameSync(currentPath, newPathTmp);
|
fs.renameSync(currentPath, newPathTmp);
|
||||||
|
|
||||||
|
// delete original file
|
||||||
|
if (fs.existsSync(args.originalLibraryFile._id)) {
|
||||||
|
fs.unlinkSync(args.originalLibraryFile._id);
|
||||||
|
}
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
fs.renameSync(newPathTmp, newPath);
|
fs.renameSync(newPathTmp, newPath);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue