[bug] Add try-catch to stat to fix race condition with delete on Windows; Add CONVERT_TEMPORARY constant for temporary convert errors

This commit is contained in:
Sergey Konovalov
2024-09-30 12:28:42 +03:00
parent e309fd2113
commit d0176ad986
4 changed files with 15 additions and 2 deletions

View File

@ -231,6 +231,7 @@ exports.CONVERT_DRM = -90;
exports.CONVERT_PASSWORD = -91;
exports.CONVERT_ICU = -92;
exports.CONVERT_LIMITS = -93;
exports.CONVERT_TEMPORARY = -94;
exports.CONVERT_DETECT = -95;
exports.CONVERT_DEAD_LETTER = -99;
exports.UPLOAD = -100;

View File

@ -170,7 +170,16 @@ function* walkDir(fsPath, results, optNoSubDir, optOnlyFolders) {
const list = yield fsReadDir(fsPath);
for (let i = 0; i < list.length; ++i) {
const file = path.join(fsPath, list[i]);
const stats = yield fsStat(file);
let stats;
try {
stats = yield fsStat(file);
} catch (e) {
//exception if fsPath not exist
stats = null;
}
if (!stats) {
continue;
}
if (stats.isDirectory()) {
if (optNoSubDir) {
optOnlyFolders && results.push(file);
@ -554,6 +563,7 @@ exports.mapAscServerErrorToOldError = function(error) {
case constants.CONVERT_CORRUPTED :
case constants.CONVERT_UNKNOWN_FORMAT :
case constants.CONVERT_READ_FILE :
case constants.CONVERT_TEMPORARY :
case constants.CONVERT :
res = -3;
break;

View File

@ -404,6 +404,8 @@ async function getUpdateResponse(ctx, cmd) {
updateTask.password = password;
}
}
} else if (constants.CONVERT_TEMPORARY === statusInfo) {
updateTask.status = commonDefines.FileStatus.ErrToReload;
} else if (constants.CONVERT_DOWNLOAD === statusInfo) {
updateTask.status = commonDefines.FileStatus.ErrToReload;
} else if (constants.CONVERT_LIMITS === statusInfo) {

View File

@ -1221,7 +1221,7 @@ function createErrorResponse(ctx, task){
ctx.logger.debug('createErrorResponse');
//simulate error response
let cmd = task.getCmd();
cmd.setStatusInfo(constants.CONVERT);
cmd.setStatusInfo(constants.CONVERT_TEMPORARY);
let res = new commonDefines.TaskQueueData();
res.setCtx(ctx);
res.setCmd(cmd);