mirror of
https://github.com/abraunegg/onedrive
synced 2024-04-27 03:42:03 +02:00
* Implement --sync-root-files to sync all files in the OneDrive root when using a sync_list file that would normally exclude these files from being synced
This commit is contained in:
parent
bac5d6f1a9
commit
caec1cb8cb
1
config
1
config
|
@ -28,3 +28,4 @@
|
|||
# min_notify_changes = "5"
|
||||
# monitor_log_frequency = "5"
|
||||
# monitor_fullscan_frequency = "10"
|
||||
# sync_root_files = "false"
|
||||
|
|
|
@ -46,6 +46,7 @@ final class Config
|
|||
boolValues["debug_https"] = false;
|
||||
boolValues["skip_dotfiles"] = false;
|
||||
boolValues["dry_run"] = false;
|
||||
boolValues["sync_root_files"] = false;
|
||||
longValues["verbose"] = log.verbose; // might be initialized by the first getopt call!
|
||||
longValues["monitor_interval"] = 45,
|
||||
longValues["min_notify_changes"] = 5;
|
||||
|
@ -266,6 +267,9 @@ final class Config
|
|||
"synchronize",
|
||||
"Perform a synchronization",
|
||||
&boolValues["synchronize"],
|
||||
"sync-root-files",
|
||||
"Sync all files in sync_dir root when using sync_list.",
|
||||
&boolValues["sync_root_files"],
|
||||
"upload-only",
|
||||
"Only upload to OneDrive, do not sync changes from OneDrive locally",
|
||||
&boolValues["upload_only"],
|
||||
|
|
|
@ -179,6 +179,7 @@ int main(string[] args)
|
|||
|
||||
// Is sync_list configured?
|
||||
if (exists(userSyncList)){
|
||||
writeln("Config option 'sync_root_files' = ", cfg.getValueBool("sync_root_files"));
|
||||
writeln("Selective sync configured = true");
|
||||
writeln("sync_list contents:");
|
||||
// Output the sync_list contents
|
||||
|
@ -189,6 +190,7 @@ int main(string[] args)
|
|||
writeln(line);
|
||||
}
|
||||
} else {
|
||||
writeln("Config option 'sync_root_files' = ", cfg.getValueBool("sync_root_files"));
|
||||
writeln("Selective sync configured = false");
|
||||
}
|
||||
|
||||
|
|
23
src/sync.d
23
src/sync.d
|
@ -858,8 +858,19 @@ final class SyncEngine
|
|||
// compute the item path to see if the path is excluded
|
||||
path = itemdb.computePath(item.driveId, item.parentId) ~ "/" ~ item.name;
|
||||
path = buildNormalizedPath(path);
|
||||
unwanted = selectiveSync.isPathExcluded(path);
|
||||
if (unwanted) log.vdebug("OneDrive change path is to be excluded by user configuration: ", path);
|
||||
if (selectiveSync.isPathExcluded(path)) {
|
||||
// selective sync advised to skip, however is this a file and are we configured to upload / download files in the root?
|
||||
if ((isItemFile(driveItem)) && (cfg.getValueBool("sync_root_files")) && (rootName(path) == "") ) {
|
||||
// This is a file
|
||||
// We are configured to sync all files in the root
|
||||
// This is a file in the logical root
|
||||
unwanted = false;
|
||||
} else {
|
||||
// path is unwanted
|
||||
unwanted = true;
|
||||
log.vdebug("OneDrive change path is to be excluded by user configuration: ", path);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.vdebug("Flagging as unwanted: item.driveId (", item.driveId,"), item.parentId (", item.parentId,") not in local database");
|
||||
unwanted = true;
|
||||
|
@ -1638,8 +1649,12 @@ final class SyncEngine
|
|||
}
|
||||
}
|
||||
if (selectiveSync.isPathExcluded(path)) {
|
||||
log.vlog("Skipping item - path excluded by sync_list: ", path);
|
||||
return;
|
||||
if ((isFile(path)) && (cfg.getValueBool("sync_root_files")) && (rootName(strip(path,"./")) == "")) {
|
||||
log.vdebug("Not skipping path due to sync_root_files inclusion: ", path);
|
||||
} else {
|
||||
log.vlog("Skipping item - path excluded by sync_list: ", path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue