mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-18 13:46:41 +02:00
Optimize local first mode
This commit is contained in:
parent
77c294ba0c
commit
613de59e7d
65
src/main.d
65
src/main.d
|
@ -976,14 +976,7 @@ void performStandardSyncProcess(string localPath, Monitor filesystemMonitor = nu
|
|||
filesystemMonitor.update(true);
|
||||
}
|
||||
|
||||
// Scan the configured 'sync_dir' for new data to upload to OneDrive
|
||||
syncEngineInstance.scanLocalFilesystemPathForNewData(localPath);
|
||||
if (appConfig.getValueBool("monitor")) {
|
||||
// Handle any new inotify events whilst the local filesystem was being scanned
|
||||
filesystemMonitor.update(true);
|
||||
}
|
||||
|
||||
// Download data from OneDrive last
|
||||
// Download data from OneDrive first so that we won't have to check local file one by one first
|
||||
syncEngineInstance.syncOneDriveAccountToLocalDisk();
|
||||
if (appConfig.getValueBool("monitor")) {
|
||||
// Cancel out any inotify events from downloading data
|
||||
|
@ -998,42 +991,40 @@ void performStandardSyncProcess(string localPath, Monitor filesystemMonitor = nu
|
|||
filesystemMonitor.update(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Perform the local database consistency check, picking up locally modified data and uploading this to OneDrive
|
||||
syncEngineInstance.performDatabaseConsistencyAndIntegrityCheck();
|
||||
if (appConfig.getValueBool("monitor")) {
|
||||
// Handle any inotify events whilst the DB was being scanned
|
||||
filesystemMonitor.update(true);
|
||||
}
|
||||
|
||||
// Is --download-only NOT configured?
|
||||
if (!appConfig.getValueBool("download_only")) {
|
||||
}
|
||||
|
||||
// Is --download-only NOT configured?
|
||||
if (!appConfig.getValueBool("download_only")) {
|
||||
|
||||
// Scan the configured 'sync_dir' for new data to upload to OneDrive
|
||||
syncEngineInstance.scanLocalFilesystemPathForNewData(localPath);
|
||||
if (appConfig.getValueBool("monitor")) {
|
||||
// Handle any new inotify events whilst the local filesystem was being scanned
|
||||
filesystemMonitor.update(true);
|
||||
}
|
||||
|
||||
// Make sure we sync any DB data to this point, but only if not in --monitor mode
|
||||
// In --monitor mode, this is handled within the 'loop', based on when the full scan true up is being performed
|
||||
if (!appConfig.getValueBool("monitor")) {
|
||||
itemDB.performVacuum();
|
||||
}
|
||||
|
||||
// Perform the final true up scan to ensure we have correctly replicated the current online state locally
|
||||
if (!appConfig.surpressLoggingOutput) {
|
||||
log.log("Performing a last examination of the most recent online data within Microsoft OneDrive to complete the reconciliation process");
|
||||
}
|
||||
// We pass in the 'appConfig.fullScanTrueUpRequired' value which then flags do we use the configured 'deltaLink'
|
||||
// If 'appConfig.fullScanTrueUpRequired' is true, we do not use the 'deltaLink' if we are in --monitor mode, thus forcing a full scan true up
|
||||
syncEngineInstance.syncOneDriveAccountToLocalDisk();
|
||||
if (appConfig.getValueBool("monitor")) {
|
||||
// Cancel out any inotify events from downloading data
|
||||
filesystemMonitor.update(false);
|
||||
}
|
||||
// Scan the configured 'sync_dir' for new data to upload to OneDrive
|
||||
syncEngineInstance.scanLocalFilesystemPathForNewData(localPath);
|
||||
if (appConfig.getValueBool("monitor")) {
|
||||
// Handle any new inotify events whilst the local filesystem was being scanned
|
||||
filesystemMonitor.update(true);
|
||||
}
|
||||
|
||||
// Make sure we sync any DB data to this point, but only if not in --monitor mode
|
||||
// In --monitor mode, this is handled within the 'loop', based on when the full scan true up is being performed
|
||||
if (!appConfig.getValueBool("monitor")) {
|
||||
itemDB.performVacuum();
|
||||
}
|
||||
|
||||
// Perform the final true up scan to ensure we have correctly replicated the current online state locally
|
||||
if (!appConfig.surpressLoggingOutput) {
|
||||
log.log("Performing a last examination of the most recent online data within Microsoft OneDrive to complete the reconciliation process");
|
||||
}
|
||||
// We pass in the 'appConfig.fullScanTrueUpRequired' value which then flags do we use the configured 'deltaLink'
|
||||
// If 'appConfig.fullScanTrueUpRequired' is true, we do not use the 'deltaLink' if we are in --monitor mode, thus forcing a full scan true up
|
||||
syncEngineInstance.syncOneDriveAccountToLocalDisk();
|
||||
if (appConfig.getValueBool("monitor")) {
|
||||
// Cancel out any inotify events from downloading data
|
||||
filesystemMonitor.update(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
21
src/sync.d
21
src/sync.d
|
@ -510,6 +510,19 @@ class SyncEngine {
|
|||
log.vdebug("Perform a Full Scan True-Up: ", appConfig.fullScanTrueUpRequired);
|
||||
// Fetch the API response of /delta to track changes on OneDrive
|
||||
fetchOneDriveDeltaAPIResponse(null, null, null);
|
||||
|
||||
// Are we doing a --download-only sync?
|
||||
if (!appConfig.getValueBool("download_only")) {
|
||||
// Do we have any existing remote items, where the content is not in-sync with local ones, that needs to be uploaded?
|
||||
if (!databaseItemsWhereContentHasChanged.empty) {
|
||||
// There are changed local files that were not in DB to upload
|
||||
log.log("Changed local items to upload to OneDrive: ", databaseItemsWhereContentHasChanged.length);
|
||||
processChangedLocalItemsToUpload();
|
||||
}
|
||||
}
|
||||
// Cleanup array memory
|
||||
databaseItemsWhereContentHasChanged = [];
|
||||
|
||||
// Process any download activities or cleanup actions
|
||||
processDownloadActivities();
|
||||
|
||||
|
@ -1629,6 +1642,14 @@ class SyncEngine {
|
|||
log.vdebug("item details to update/insert: ", newDatabaseItem);
|
||||
itemDB.upsert(newDatabaseItem);
|
||||
return;
|
||||
} else if (appConfig.getValueBool("local_first")) {
|
||||
// Item is not in database but exists locally
|
||||
// In local_first mode, upload it instead
|
||||
log.vdebug("Skipping OneDrive change as this is determined to be unwanted due to local_first is used, upload it instead.");
|
||||
// save in database for so it can be found for later updates
|
||||
itemDB.upsert(newDatabaseItem);
|
||||
databaseItemsWhereContentHasChanged ~= [newDatabaseItem.driveId, newDatabaseItem.id, newItemPath];
|
||||
return;
|
||||
} else {
|
||||
// Item details from OneDrive and local item details in database are NOT in-sync
|
||||
log.vdebug("The item to sync exists locally but is NOT in the local database - otherwise this would be handled as changed item");
|
||||
|
|
Loading…
Reference in a new issue