mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-17 21:26:41 +02:00
Fix overwriting local files with older versions from OneDrive when items.sqlite3 does not exist and --resync is not used (#1717)
* Resolve issue where --resync is not used and items.sqlite3 is not available at application startup, local files, whilst potentially newer, will not be preserved thus leading to a potential data loss scenario
This commit is contained in:
parent
ac2e07526a
commit
2f47beab60
11
src/sync.d
11
src/sync.d
|
@ -2526,14 +2526,13 @@ final class SyncEngine
|
|||
// file exists locally but is not in the sqlite database - maybe a failed download?
|
||||
log.vlog("Local item does not exist in local database - replacing with file from OneDrive - failed download?");
|
||||
|
||||
// was --resync issued?
|
||||
if (cfg.getValueBool("resync")) {
|
||||
// in a --resync scenario we have zero way of knowing IF the local file is meant to be the right file
|
||||
|
||||
// in a --resync scenario or if items.sqlite3 was deleted before startup we have zero way of knowing IF the local file is meant to be the right file
|
||||
// we have passed the following checks:
|
||||
// 1. file exists locally
|
||||
// 2. local modified time > remote modified time
|
||||
// 3. id is not in the database
|
||||
// 4. --resync was issued
|
||||
|
||||
auto ext = extension(path);
|
||||
auto newPath = path.chomp(ext) ~ "-" ~ deviceName ~ ext;
|
||||
// has the user configured to IGNORE local data protection rules?
|
||||
|
@ -2542,7 +2541,7 @@ final class SyncEngine
|
|||
log.vlog("WARNING: Local Data Protection has been disabled. You may experience data loss on this file: ", path);
|
||||
} else {
|
||||
// local data protection is configured, renaming local file
|
||||
log.vlog("The local item is out-of-sync with OneDrive, renaming to preserve existing file and prevent data loss due to --resync: ", path, " -> ", newPath);
|
||||
log.vlog("The local item is out-of-sync with OneDrive, renaming to preserve existing file and prevent local data loss: ", path, " -> ", newPath);
|
||||
// perform the rename action of the local file
|
||||
if (!dryRun) {
|
||||
safeRename(path);
|
||||
|
@ -2551,7 +2550,7 @@ final class SyncEngine
|
|||
log.vdebug("DRY-RUN: Skipping local file rename");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// remote file is newer than local item
|
||||
|
|
Loading…
Reference in a new issue