Skip to content

Commit

Permalink
Merge pull request #160 from pierotofy/corrupt
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
pierotofy authored Jun 21, 2021
2 parents 8eb7ae9 + c5b5fa0 commit bb8b7bd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion libs/TaskManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ class TaskManager{
try{
tasks = JSON.parse(data.toString());
}catch(e){
done(new Error(`Could not load task list. It looks like the ${TASKS_DUMP_FILE} is corrupted (${e.message}). Please manually delete the file and try again.`));
logger.warn(`Could not load task list. It looks like the ${TASKS_DUMP_FILE} is corrupted (${e.message}).`);
if (done !== undefined) done();
return;
}

Expand Down
22 changes: 20 additions & 2 deletions libs/taskNew.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,26 @@ module.exports = {
// Move all uploads to data/<uuid>/images dir (if any)
cb => fs.mkdir(destPath, undefined, cb),
cb => fs.mkdir(destGcpPath, undefined, cb),
cb => mv(srcPath, destImagesPath, cb),

cb => {
// We attempt to do this multiple times,
// as antivirus software sometimes is scanning
// the folder while we try to move it, resulting in
// an operation not permitted error
let retries = 0;

const move = () => {
mv(srcPath, destImagesPath, err => {
if (!err) cb(); // Done
else{
if (++retries < 20){
logger.warn(`Cannot move ${srcPath}, probably caused by antivirus software (please disable it or add an exception), retrying (${retries})...`);
setTimeout(2000, move);
}else cb(err);
}
});
}
move();
},
// Zip files handling
cb => {
const handleSeed = (cb) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NodeODM",
"version": "2.1.8",
"version": "2.1.9",
"description": "REST API to access ODM",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit bb8b7bd

Please sign in to comment.