mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 15:38:19 -07:00
Add moveFileAndValidate
This commit is contained in:
parent
cf1b27c26d
commit
d7c16474cf
7 changed files with 237 additions and 18 deletions
|
|
@ -40,7 +40,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fs_1 = require("fs");
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
var normJoinPath_1 = __importDefault(require("../../../../FlowHelpers/1.0.0/normJoinPath"));
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
|
|
@ -126,7 +125,11 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|||
args.jobLog("Input path: ".concat(args.inputFileObj._id));
|
||||
args.jobLog("Output path: ".concat(ouputFilePath));
|
||||
args.deps.fsextra.ensureDirSync(outputPath);
|
||||
return [4 /*yield*/, fs_1.promises.rename(args.inputFileObj._id, ouputFilePath)];
|
||||
return [4 /*yield*/, (0, fileUtils_1.moveFileAndValidate)({
|
||||
inputPath: args.inputFileObj._id,
|
||||
outputPath: ouputFilePath,
|
||||
args: args,
|
||||
})];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/, {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.plugin = exports.details = void 0;
|
||||
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
||||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
||||
var details = function () { return ({
|
||||
name: 'Replace Original File',
|
||||
|
|
@ -99,15 +100,27 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|||
if (fs.existsSync(newPath)) {
|
||||
fs.unlinkSync(newPath);
|
||||
}
|
||||
fs.renameSync(currentPath, newPathTmp);
|
||||
return [4 /*yield*/, (0, fileUtils_1.moveFileAndValidate)({
|
||||
inputPath: currentPath,
|
||||
outputPath: newPathTmp,
|
||||
args: args,
|
||||
})];
|
||||
case 2:
|
||||
_a.sent();
|
||||
// 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:
|
||||
case 3:
|
||||
_a.sent();
|
||||
return [4 /*yield*/, (0, fileUtils_1.moveFileAndValidate)({
|
||||
inputPath: newPathTmp,
|
||||
outputPath: newPath,
|
||||
args: args,
|
||||
})];
|
||||
case 4:
|
||||
_a.sent();
|
||||
fs.renameSync(newPathTmp, newPath);
|
||||
return [2 /*return*/, {
|
||||
outputFileObj: {
|
||||
_id: newPath,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue