|
|
|
@ -69,260 +69,248 @@ var compareOldNew = function (_a) {
|
|
|
|
+ " cache file of size ".concat(sourceFileSize));
|
|
|
|
+ " cache file of size ".concat(sourceFileSize));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var tryMove = function (_a) {
|
|
|
|
var tryMove = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
|
|
var sourcePath = _a.sourcePath, destinationPath = _a.destinationPath, sourceFileSize = _a.sourceFileSize, args = _a.args;
|
|
|
|
var error, err_2, destinationSize;
|
|
|
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
|
|
var sourcePath = _b.sourcePath, destinationPath = _b.destinationPath, sourceFileSize = _b.sourceFileSize, args = _b.args;
|
|
|
|
var error, err_2, destinationSize;
|
|
|
|
return __generator(this, function (_c) {
|
|
|
|
return __generator(this, function (_b) {
|
|
|
|
switch (_c.label) {
|
|
|
|
switch (_b.label) {
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
args.jobLog("Attempting move from ".concat(sourcePath, " to ").concat(destinationPath, ", method 1"));
|
|
|
|
args.jobLog("Attempting move from ".concat(sourcePath, " to ").concat(destinationPath, ", method 1"));
|
|
|
|
error = false;
|
|
|
|
error = false;
|
|
|
|
_c.label = 1;
|
|
|
|
_b.label = 1;
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
_c.trys.push([1, 3, , 4]);
|
|
|
|
_b.trys.push([1, 3, , 4]);
|
|
|
|
return [4 /*yield*/, fs_1.promises.rename(sourcePath, destinationPath)];
|
|
|
|
return [4 /*yield*/, fs_1.promises.rename(sourcePath, destinationPath)];
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
_c.sent();
|
|
|
|
_b.sent();
|
|
|
|
return [3 /*break*/, 4];
|
|
|
|
return [3 /*break*/, 4];
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
err_2 = _c.sent();
|
|
|
|
err_2 = _b.sent();
|
|
|
|
error = true;
|
|
|
|
error = true;
|
|
|
|
args.jobLog("File move error: ".concat(JSON.stringify(err_2)));
|
|
|
|
args.jobLog("File move error: ".concat(JSON.stringify(err_2)));
|
|
|
|
return [3 /*break*/, 4];
|
|
|
|
return [3 /*break*/, 4];
|
|
|
|
case 4: return [4 /*yield*/, getSizeBytes(destinationPath)];
|
|
|
|
case 4: return [4 /*yield*/, getSizeBytes(destinationPath)];
|
|
|
|
case 5:
|
|
|
|
case 5:
|
|
|
|
destinationSize = _c.sent();
|
|
|
|
destinationSize = _b.sent();
|
|
|
|
compareOldNew({
|
|
|
|
compareOldNew({
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
destinationSize: destinationSize,
|
|
|
|
destinationSize: destinationSize,
|
|
|
|
args: args,
|
|
|
|
args: args,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (error || destinationSize !== sourceFileSize) {
|
|
|
|
if (error || destinationSize !== sourceFileSize) {
|
|
|
|
return [2 /*return*/, false];
|
|
|
|
return [2 /*return*/, false];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}); };
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
var tryMvdir = function (_a) {
|
|
|
|
var tryMvdir = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
|
|
var sourcePath = _a.sourcePath, destinationPath = _a.destinationPath, sourceFileSize = _a.sourceFileSize, args = _a.args;
|
|
|
|
var error, destinationSize;
|
|
|
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
|
|
var sourcePath = _b.sourcePath, destinationPath = _b.destinationPath, sourceFileSize = _b.sourceFileSize, args = _b.args;
|
|
|
|
var error, destinationSize;
|
|
|
|
return __generator(this, function (_c) {
|
|
|
|
return __generator(this, function (_b) {
|
|
|
|
switch (_c.label) {
|
|
|
|
switch (_b.label) {
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
args.jobLog("Attempting move from ".concat(sourcePath, " to ").concat(destinationPath, ", method 2"));
|
|
|
|
args.jobLog("Attempting move from ".concat(sourcePath, " to ").concat(destinationPath, ", method 2"));
|
|
|
|
error = false;
|
|
|
|
error = false;
|
|
|
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
|
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
|
|
// fs-extra and move-file don't work when destination is on windows root of drive
|
|
|
|
// fs-extra and move-file don't work when destination is on windows root of drive
|
|
|
|
// mvdir will try to move else fall back to copy/unlink
|
|
|
|
// mvdir will try to move else fall back to copy/unlink
|
|
|
|
// potential bug on unraid
|
|
|
|
// potential bug on unraid
|
|
|
|
args.deps.mvdir(sourcePath, destinationPath, { overwrite: true })
|
|
|
|
args.deps.mvdir(sourcePath, destinationPath, { overwrite: true })
|
|
|
|
.then(function () {
|
|
|
|
.then(function () {
|
|
|
|
resolve(true);
|
|
|
|
resolve(true);
|
|
|
|
}).catch(function (err) {
|
|
|
|
}).catch(function (err) {
|
|
|
|
error = true;
|
|
|
|
error = true;
|
|
|
|
args.jobLog("File move error: ".concat(err));
|
|
|
|
args.jobLog("File move error: ".concat(err));
|
|
|
|
resolve(err);
|
|
|
|
resolve(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})];
|
|
|
|
})];
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
_c.sent();
|
|
|
|
_b.sent();
|
|
|
|
return [4 /*yield*/, getSizeBytes(destinationPath)];
|
|
|
|
return [4 /*yield*/, getSizeBytes(destinationPath)];
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
destinationSize = _c.sent();
|
|
|
|
destinationSize = _b.sent();
|
|
|
|
compareOldNew({
|
|
|
|
compareOldNew({
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
destinationSize: destinationSize,
|
|
|
|
destinationSize: destinationSize,
|
|
|
|
args: args,
|
|
|
|
args: args,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (error || destinationSize !== sourceFileSize) {
|
|
|
|
if (error || destinationSize !== sourceFileSize) {
|
|
|
|
return [2 /*return*/, false];
|
|
|
|
return [2 /*return*/, false];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}); };
|
|
|
|
// Keep in e.g. https://github.com/HaveAGitGat/Tdarr/issues/858
|
|
|
|
// Keep in e.g. https://github.com/HaveAGitGat/Tdarr/issues/858
|
|
|
|
var tyNcp = function (_a) {
|
|
|
|
var tyNcp = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
|
|
var sourcePath = _a.sourcePath, destinationPath = _a.destinationPath, sourceFileSize = _a.sourceFileSize, args = _a.args;
|
|
|
|
var error_1, destinationSize;
|
|
|
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
|
|
var sourcePath = _b.sourcePath, destinationPath = _b.destinationPath, sourceFileSize = _b.sourceFileSize, args = _b.args;
|
|
|
|
var error_1, destinationSize;
|
|
|
|
return __generator(this, function (_c) {
|
|
|
|
return __generator(this, function (_b) {
|
|
|
|
switch (_c.label) {
|
|
|
|
switch (_b.label) {
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
if (!args.deps.ncp) return [3 /*break*/, 3];
|
|
|
|
if (!args.deps.ncp) return [3 /*break*/, 3];
|
|
|
|
args.jobLog("Attempting copy from ".concat(sourcePath, " to ").concat(destinationPath, " , method 1"));
|
|
|
|
args.jobLog("Attempting copy from ".concat(sourcePath, " to ").concat(destinationPath, " , method 1"));
|
|
|
|
error_1 = false;
|
|
|
|
error_1 = false;
|
|
|
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
|
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
|
|
args.deps.ncp(sourcePath, destinationPath, function (err) {
|
|
|
|
args.deps.ncp(sourcePath, destinationPath, function (err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
error_1 = true;
|
|
|
|
error_1 = true;
|
|
|
|
args.jobLog("File copy error: ".concat(err));
|
|
|
|
args.jobLog("File copy error: ".concat(err));
|
|
|
|
resolve(err);
|
|
|
|
resolve(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
resolve(true);
|
|
|
|
resolve(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})];
|
|
|
|
})];
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
_c.sent();
|
|
|
|
_b.sent();
|
|
|
|
return [4 /*yield*/, getSizeBytes(destinationPath)];
|
|
|
|
return [4 /*yield*/, getSizeBytes(destinationPath)];
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
destinationSize = _c.sent();
|
|
|
|
destinationSize = _b.sent();
|
|
|
|
compareOldNew({
|
|
|
|
compareOldNew({
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
destinationSize: destinationSize,
|
|
|
|
destinationSize: destinationSize,
|
|
|
|
args: args,
|
|
|
|
args: args,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (error_1 || destinationSize !== sourceFileSize) {
|
|
|
|
if (error_1 || destinationSize !== sourceFileSize) {
|
|
|
|
return [2 /*return*/, false];
|
|
|
|
return [2 /*return*/, false];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
case 3: return [2 /*return*/, false];
|
|
|
|
case 3: return [2 /*return*/, false];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}); };
|
|
|
|
var tryNormalCopy = function (_a) {
|
|
|
|
var tryNormalCopy = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
|
|
var sourcePath = _a.sourcePath, destinationPath = _a.destinationPath, sourceFileSize = _a.sourceFileSize, args = _a.args;
|
|
|
|
var error, err_3, destinationSize;
|
|
|
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
|
|
var sourcePath = _b.sourcePath, destinationPath = _b.destinationPath, sourceFileSize = _b.sourceFileSize, args = _b.args;
|
|
|
|
var error, err_3, destinationSize;
|
|
|
|
return __generator(this, function (_c) {
|
|
|
|
return __generator(this, function (_b) {
|
|
|
|
switch (_c.label) {
|
|
|
|
switch (_b.label) {
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
args.jobLog("Attempting copy from ".concat(sourcePath, " to ").concat(destinationPath, " , method 2"));
|
|
|
|
args.jobLog("Attempting copy from ".concat(sourcePath, " to ").concat(destinationPath, " , method 2"));
|
|
|
|
error = false;
|
|
|
|
error = false;
|
|
|
|
_c.label = 1;
|
|
|
|
_b.label = 1;
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
_c.trys.push([1, 3, , 4]);
|
|
|
|
_b.trys.push([1, 3, , 4]);
|
|
|
|
return [4 /*yield*/, fs_1.promises.copyFile(sourcePath, destinationPath)];
|
|
|
|
return [4 /*yield*/, fs_1.promises.copyFile(sourcePath, destinationPath)];
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
_c.sent();
|
|
|
|
_b.sent();
|
|
|
|
return [3 /*break*/, 4];
|
|
|
|
return [3 /*break*/, 4];
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
err_3 = _c.sent();
|
|
|
|
err_3 = _b.sent();
|
|
|
|
error = true;
|
|
|
|
error = true;
|
|
|
|
args.jobLog("File copy error: ".concat(JSON.stringify(err_3)));
|
|
|
|
args.jobLog("File copy error: ".concat(JSON.stringify(err_3)));
|
|
|
|
return [3 /*break*/, 4];
|
|
|
|
return [3 /*break*/, 4];
|
|
|
|
case 4: return [4 /*yield*/, getSizeBytes(destinationPath)];
|
|
|
|
case 4: return [4 /*yield*/, getSizeBytes(destinationPath)];
|
|
|
|
case 5:
|
|
|
|
case 5:
|
|
|
|
destinationSize = _c.sent();
|
|
|
|
destinationSize = _b.sent();
|
|
|
|
compareOldNew({
|
|
|
|
compareOldNew({
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
destinationSize: destinationSize,
|
|
|
|
destinationSize: destinationSize,
|
|
|
|
args: args,
|
|
|
|
args: args,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (error || destinationSize !== sourceFileSize) {
|
|
|
|
if (error || destinationSize !== sourceFileSize) {
|
|
|
|
return [2 /*return*/, false];
|
|
|
|
return [2 /*return*/, false];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}); };
|
|
|
|
var cleanSourceFile = function (_a) {
|
|
|
|
var cleanSourceFile = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
|
|
var args = _a.args, sourcePath = _a.sourcePath;
|
|
|
|
var err_4;
|
|
|
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
|
|
var args = _b.args, sourcePath = _b.sourcePath;
|
|
|
|
var err_4;
|
|
|
|
return __generator(this, function (_c) {
|
|
|
|
return __generator(this, function (_b) {
|
|
|
|
switch (_c.label) {
|
|
|
|
switch (_b.label) {
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
_c.trys.push([0, 2, , 3]);
|
|
|
|
_b.trys.push([0, 2, , 3]);
|
|
|
|
args.jobLog("Deleting source file ".concat(sourcePath));
|
|
|
|
args.jobLog("Deleting source file ".concat(sourcePath));
|
|
|
|
return [4 /*yield*/, fs_1.promises.unlink(sourcePath)];
|
|
|
|
return [4 /*yield*/, fs_1.promises.unlink(sourcePath)];
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
_c.sent();
|
|
|
|
_b.sent();
|
|
|
|
return [3 /*break*/, 3];
|
|
|
|
return [3 /*break*/, 3];
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
err_4 = _c.sent();
|
|
|
|
err_4 = _b.sent();
|
|
|
|
args.jobLog("Failed to delete source file ".concat(sourcePath, ": ").concat(JSON.stringify(err_4)));
|
|
|
|
args.jobLog("Failed to delete source file ".concat(sourcePath, ": ").concat(JSON.stringify(err_4)));
|
|
|
|
return [3 /*break*/, 3];
|
|
|
|
return [3 /*break*/, 3];
|
|
|
|
case 3: return [2 /*return*/];
|
|
|
|
case 3: return [2 /*return*/];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}); };
|
|
|
|
var fileMoveOrCopy = function (_a) {
|
|
|
|
var fileMoveOrCopy = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
|
|
var operation = _a.operation, sourcePath = _a.sourcePath, destinationPath = _a.destinationPath, args = _a.args;
|
|
|
|
var sourceFileSize, moved, ncpd, copied;
|
|
|
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
|
|
var operation = _b.operation, sourcePath = _b.sourcePath, destinationPath = _b.destinationPath, args = _b.args;
|
|
|
|
var sourceFileSize, moved, ncpd, copied;
|
|
|
|
return __generator(this, function (_c) {
|
|
|
|
return __generator(this, function (_b) {
|
|
|
|
switch (_c.label) {
|
|
|
|
switch (_b.label) {
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
args.jobLog('Calculating cache file size in bytes');
|
|
|
|
args.jobLog('Calculating cache file size in bytes');
|
|
|
|
return [4 /*yield*/, getSizeBytes(sourcePath)];
|
|
|
|
return [4 /*yield*/, getSizeBytes(sourcePath)];
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
sourceFileSize = _c.sent();
|
|
|
|
sourceFileSize = _b.sent();
|
|
|
|
args.jobLog("".concat(sourceFileSize));
|
|
|
|
args.jobLog("".concat(sourceFileSize));
|
|
|
|
if (!(operation === 'move')) return [3 /*break*/, 3];
|
|
|
|
if (!(operation === 'move')) return [3 /*break*/, 3];
|
|
|
|
return [4 /*yield*/, tryMove({
|
|
|
|
return [4 /*yield*/, tryMove({
|
|
|
|
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
|
|
|
|
destinationPath: destinationPath,
|
|
|
|
|
|
|
|
args: args,
|
|
|
|
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
|
|
|
|
})];
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
moved = _b.sent();
|
|
|
|
|
|
|
|
if (moved) {
|
|
|
|
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// disable: https://github.com/HaveAGitGat/Tdarr/issues/885
|
|
|
|
|
|
|
|
// const mvdird = await tryMvdir({
|
|
|
|
|
|
|
|
// sourcePath,
|
|
|
|
|
|
|
|
// destinationPath,
|
|
|
|
|
|
|
|
// args,
|
|
|
|
|
|
|
|
// sourceFileSize,
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// if (mvdird) {
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
args.jobLog('Failed to move file, trying copy');
|
|
|
|
|
|
|
|
_b.label = 3;
|
|
|
|
|
|
|
|
case 3: return [4 /*yield*/, tyNcp({
|
|
|
|
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
destinationPath: destinationPath,
|
|
|
|
destinationPath: destinationPath,
|
|
|
|
args: args,
|
|
|
|
args: args,
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
})];
|
|
|
|
})];
|
|
|
|
case 4:
|
|
|
|
case 2:
|
|
|
|
ncpd = _b.sent();
|
|
|
|
moved = _c.sent();
|
|
|
|
if (!ncpd) return [3 /*break*/, 7];
|
|
|
|
if (moved) {
|
|
|
|
if (!(operation === 'move')) return [3 /*break*/, 6];
|
|
|
|
return [2 /*return*/, true];
|
|
|
|
return [4 /*yield*/, cleanSourceFile({
|
|
|
|
}
|
|
|
|
args: args,
|
|
|
|
// disable: https://github.com/HaveAGitGat/Tdarr/issues/885
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
// const mvdird = await tryMvdir({
|
|
|
|
})];
|
|
|
|
// sourcePath,
|
|
|
|
case 5:
|
|
|
|
// destinationPath,
|
|
|
|
_b.sent();
|
|
|
|
// args,
|
|
|
|
_b.label = 6;
|
|
|
|
// sourceFileSize,
|
|
|
|
case 6: return [2 /*return*/, true];
|
|
|
|
// });
|
|
|
|
case 7: return [4 /*yield*/, tryNormalCopy({
|
|
|
|
// if (mvdird) {
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
args.jobLog('Failed to move file, trying copy');
|
|
|
|
|
|
|
|
_c.label = 3;
|
|
|
|
|
|
|
|
case 3: return [4 /*yield*/, tyNcp({
|
|
|
|
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
|
|
|
|
destinationPath: destinationPath,
|
|
|
|
|
|
|
|
args: args,
|
|
|
|
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
|
|
|
|
})];
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
|
|
ncpd = _c.sent();
|
|
|
|
|
|
|
|
if (!ncpd) return [3 /*break*/, 7];
|
|
|
|
|
|
|
|
if (!(operation === 'move')) return [3 /*break*/, 6];
|
|
|
|
|
|
|
|
return [4 /*yield*/, cleanSourceFile({
|
|
|
|
|
|
|
|
args: args,
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
destinationPath: destinationPath,
|
|
|
|
})];
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
|
|
_c.sent();
|
|
|
|
|
|
|
|
_c.label = 6;
|
|
|
|
|
|
|
|
case 6: return [2 /*return*/, true];
|
|
|
|
|
|
|
|
case 7: return [4 /*yield*/, tryNormalCopy({
|
|
|
|
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
|
|
|
|
destinationPath: destinationPath,
|
|
|
|
|
|
|
|
args: args,
|
|
|
|
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
|
|
|
|
})];
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
|
|
|
|
copied = _c.sent();
|
|
|
|
|
|
|
|
if (!copied) return [3 /*break*/, 11];
|
|
|
|
|
|
|
|
if (!(operation === 'move')) return [3 /*break*/, 10];
|
|
|
|
|
|
|
|
return [4 /*yield*/, cleanSourceFile({
|
|
|
|
args: args,
|
|
|
|
args: args,
|
|
|
|
sourceFileSize: sourceFileSize,
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
})];
|
|
|
|
})];
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
copied = _b.sent();
|
|
|
|
_c.sent();
|
|
|
|
if (!copied) return [3 /*break*/, 11];
|
|
|
|
_c.label = 10;
|
|
|
|
if (!(operation === 'move')) return [3 /*break*/, 10];
|
|
|
|
case 10: return [2 /*return*/, true];
|
|
|
|
return [4 /*yield*/, cleanSourceFile({
|
|
|
|
case 11: throw new Error("Failed to ".concat(operation, " file"));
|
|
|
|
args: args,
|
|
|
|
}
|
|
|
|
sourcePath: sourcePath,
|
|
|
|
|
|
|
|
})];
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
|
|
|
|
_b.sent();
|
|
|
|
|
|
|
|
_b.label = 10;
|
|
|
|
|
|
|
|
case 10: return [2 /*return*/, true];
|
|
|
|
|
|
|
|
case 11: throw new Error("Failed to ".concat(operation, " file"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}); };
|
|
|
|
exports.default = fileMoveOrCopy;
|
|
|
|
exports.default = fileMoveOrCopy;
|
|
|
|
|