mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-02 05:52:16 +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);
|
filesystemMonitor.update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan the configured 'sync_dir' for new data to upload to OneDrive
|
// Download data from OneDrive first so that we won't have to check local file one by one first
|
||||||
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
|
|
||||||
syncEngineInstance.syncOneDriveAccountToLocalDisk();
|
syncEngineInstance.syncOneDriveAccountToLocalDisk();
|
||||||
if (appConfig.getValueBool("monitor")) {
|
if (appConfig.getValueBool("monitor")) {
|
||||||
// Cancel out any inotify events from downloading data
|
// Cancel out any inotify events from downloading data
|
||||||
|
@ -998,42 +991,40 @@ void performStandardSyncProcess(string localPath, Monitor filesystemMonitor = nu
|
||||||
filesystemMonitor.update(false);
|
filesystemMonitor.update(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Perform the local database consistency check, picking up locally modified data and uploading this to OneDrive
|
// Perform the local database consistency check, picking up locally modified data and uploading this to OneDrive
|
||||||
syncEngineInstance.performDatabaseConsistencyAndIntegrityCheck();
|
syncEngineInstance.performDatabaseConsistencyAndIntegrityCheck();
|
||||||
if (appConfig.getValueBool("monitor")) {
|
if (appConfig.getValueBool("monitor")) {
|
||||||
// Handle any inotify events whilst the DB was being scanned
|
// Handle any inotify events whilst the DB was being scanned
|
||||||
filesystemMonitor.update(true);
|
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
|
// Scan the configured 'sync_dir' for new data to upload to OneDrive
|
||||||
syncEngineInstance.scanLocalFilesystemPathForNewData(localPath);
|
syncEngineInstance.scanLocalFilesystemPathForNewData(localPath);
|
||||||
if (appConfig.getValueBool("monitor")) {
|
if (appConfig.getValueBool("monitor")) {
|
||||||
// Handle any new inotify events whilst the local filesystem was being scanned
|
// Handle any new inotify events whilst the local filesystem was being scanned
|
||||||
filesystemMonitor.update(true);
|
filesystemMonitor.update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we sync any DB data to this point, but only if not in --monitor mode
|
// 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
|
// In --monitor mode, this is handled within the 'loop', based on when the full scan true up is being performed
|
||||||
if (!appConfig.getValueBool("monitor")) {
|
if (!appConfig.getValueBool("monitor")) {
|
||||||
itemDB.performVacuum();
|
itemDB.performVacuum();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the final true up scan to ensure we have correctly replicated the current online state locally
|
// Perform the final true up scan to ensure we have correctly replicated the current online state locally
|
||||||
if (!appConfig.surpressLoggingOutput) {
|
if (!appConfig.surpressLoggingOutput) {
|
||||||
log.log("Performing a last examination of the most recent online data within Microsoft OneDrive to complete the reconciliation process");
|
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'
|
// 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
|
// 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();
|
syncEngineInstance.syncOneDriveAccountToLocalDisk();
|
||||||
if (appConfig.getValueBool("monitor")) {
|
if (appConfig.getValueBool("monitor")) {
|
||||||
// Cancel out any inotify events from downloading data
|
// Cancel out any inotify events from downloading data
|
||||||
filesystemMonitor.update(false);
|
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);
|
log.vdebug("Perform a Full Scan True-Up: ", appConfig.fullScanTrueUpRequired);
|
||||||
// Fetch the API response of /delta to track changes on OneDrive
|
// Fetch the API response of /delta to track changes on OneDrive
|
||||||
fetchOneDriveDeltaAPIResponse(null, null, null);
|
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
|
// Process any download activities or cleanup actions
|
||||||
processDownloadActivities();
|
processDownloadActivities();
|
||||||
|
|
||||||
|
@ -1629,6 +1642,14 @@ class SyncEngine {
|
||||||
log.vdebug("item details to update/insert: ", newDatabaseItem);
|
log.vdebug("item details to update/insert: ", newDatabaseItem);
|
||||||
itemDB.upsert(newDatabaseItem);
|
itemDB.upsert(newDatabaseItem);
|
||||||
return;
|
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 {
|
} else {
|
||||||
// Item details from OneDrive and local item details in database are NOT in-sync
|
// 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");
|
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