fixed an error when files were closed during sync

This commit is contained in:
antelle 2020-05-30 07:47:52 +02:00
parent b41b291e60
commit 7394754b6f
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 12 additions and 0 deletions

View File

@ -833,6 +833,9 @@ class AppModel {
if (file.syncing) {
return callback && callback('Sync in progress');
}
if (!file.active) {
return callback && callback('File is closed');
}
if (!options) {
options = {};
}
@ -872,6 +875,9 @@ class AppModel {
if (!err) {
savedToCache = true;
}
if (!file.active) {
return callback && callback('File is closed');
}
logger.info('Sync finished', err || 'no error');
file.setSyncComplete(path, storage, err ? err.toString() : null, savedToCache);
fileInfo.set({
@ -925,6 +931,9 @@ class AppModel {
logger.info('Load from storage, attempt ' + loadLoops);
Storage[storage].load(path, opts, (err, data, stat) => {
logger.info('Load from storage', stat, err || 'no error');
if (!file.active) {
return complete('File is closed');
}
if (err) {
return complete(err);
}
@ -1024,6 +1033,9 @@ class AppModel {
};
logger.info('Stat file');
Storage[storage].stat(path, opts, (err, stat) => {
if (!file.active) {
return complete('File is closed');
}
if (err) {
if (err.notFound) {
logger.info('File does not exist in storage, creating');