mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[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:
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user