mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-23 16:12:12 +02:00
Fix handling of skip_dir, skip_file & sync_list config options (#686)
* config option skip_dir should only be applied to directories * config option skip_file should only be applied to files * If 'directory' is in 'skip_file' then upload skip reason erroneously lists sync_list as reason for skipping * update log output when something is excluded * where a path is to be excluded via sync_list, only exclude via sync_list & not check skip_dir & skip_file as well
This commit is contained in:
parent
8b969deae8
commit
57cf29783a
|
@ -83,7 +83,7 @@ final class Monitor
|
||||||
if (selectiveSync.isFileNameExcluded(baseName(dirname))) {
|
if (selectiveSync.isFileNameExcluded(baseName(dirname))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (selectiveSync.isPathExcluded(buildNormalizedPath(dirname))) {
|
if (selectiveSync.isPathExcludedViaSyncList(buildNormalizedPath(dirname))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ final class Monitor
|
||||||
if (selectiveSync.isFileNameExcluded(strip(path,"./"))) {
|
if (selectiveSync.isFileNameExcluded(strip(path,"./"))) {
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
if (selectiveSync.isPathExcluded(path)) {
|
if (selectiveSync.isPathExcludedViaSyncList(path)) {
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,14 @@ final class SelectiveSync
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// config sync_list file handling
|
// Match against sync_list only
|
||||||
bool isPathExcluded(string path)
|
bool isPathExcludedViaSyncList(string path)
|
||||||
|
{
|
||||||
|
return .isPathExcluded(path, paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match against skip_dir, skip_file & sync_list entries
|
||||||
|
bool isPathExcludedMatchAll(string path)
|
||||||
{
|
{
|
||||||
return .isPathExcluded(path, paths) || .isPathMatched(path, mask) || .isPathMatched(path, dirmask);
|
return .isPathExcluded(path, paths) || .isPathMatched(path, mask) || .isPathMatched(path, dirmask);
|
||||||
}
|
}
|
||||||
|
|
41
src/sync.d
41
src/sync.d
|
@ -1054,7 +1054,7 @@ final class SyncEngine
|
||||||
// item exists in database, most likely moved out of scope for current client configuration
|
// item exists in database, most likely moved out of scope for current client configuration
|
||||||
log.vdebug("This item was previously synced / seen by the client");
|
log.vdebug("This item was previously synced / seen by the client");
|
||||||
if (("name" in driveItem["parentReference"]) != null) {
|
if (("name" in driveItem["parentReference"]) != null) {
|
||||||
if (selectiveSync.isPathExcluded(driveItem["parentReference"]["name"].str)) {
|
if (selectiveSync.isPathExcludedViaSyncList(driveItem["parentReference"]["name"].str)) {
|
||||||
// Previously synced item is now out of scope as it has been moved out of what is included in sync_list
|
// Previously synced item is now out of scope as it has been moved out of what is included in sync_list
|
||||||
log.vdebug("This previously synced item is now excluded from being synced due to sync_list exclusion");
|
log.vdebug("This previously synced item is now excluded from being synced due to sync_list exclusion");
|
||||||
// flag to delete local file as it now is no longer in sync with OneDrive
|
// flag to delete local file as it now is no longer in sync with OneDrive
|
||||||
|
@ -1065,18 +1065,25 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this is a directory to skip
|
// Check if this is excluded by config option: skip_dir
|
||||||
if (!unwanted) {
|
if (!unwanted) {
|
||||||
// Only check path if config is != ""
|
// Only check path if config is != ""
|
||||||
if (cfg.getValueString("skip_dir") != "") {
|
if (cfg.getValueString("skip_dir") != "") {
|
||||||
unwanted = selectiveSync.isDirNameExcluded(item.name);
|
// Is the item a folder?
|
||||||
if (unwanted) log.vlog("Skipping item - excluded by skip_dir config: ", item.name);
|
if (isItemFolder(driveItem)) {
|
||||||
|
unwanted = selectiveSync.isDirNameExcluded(item.name);
|
||||||
|
if (unwanted) log.vlog("Skipping item - excluded by skip_dir config: ", item.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if this is a file to skip
|
|
||||||
|
// Check if this is excluded by config option: skip_file
|
||||||
if (!unwanted) {
|
if (!unwanted) {
|
||||||
unwanted = selectiveSync.isFileNameExcluded(item.name);
|
// Is the item a file?
|
||||||
if (unwanted) log.vlog("Skipping item - excluded by skip_file config: ", item.name);
|
if (isItemFile(driveItem)) {
|
||||||
|
unwanted = selectiveSync.isFileNameExcluded(item.name);
|
||||||
|
if (unwanted) log.vlog("Skipping item - excluded by skip_file config: ", item.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the item type
|
// check the item type
|
||||||
|
@ -1103,7 +1110,7 @@ final class SyncEngine
|
||||||
// compute the item path to see if the path is excluded
|
// compute the item path to see if the path is excluded
|
||||||
path = itemdb.computePath(item.driveId, item.parentId) ~ "/" ~ item.name;
|
path = itemdb.computePath(item.driveId, item.parentId) ~ "/" ~ item.name;
|
||||||
path = buildNormalizedPath(path);
|
path = buildNormalizedPath(path);
|
||||||
if (selectiveSync.isPathExcluded(path)) {
|
if (selectiveSync.isPathExcludedViaSyncList(path)) {
|
||||||
// selective sync advised to skip, however is this a file and are we configured to upload / download files in the root?
|
// 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) == "") ) {
|
if ((isItemFile(driveItem)) && (cfg.getValueBool("sync_root_files")) && (rootName(path) == "") ) {
|
||||||
// This is a file
|
// This is a file
|
||||||
|
@ -1113,7 +1120,7 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// path is unwanted
|
// path is unwanted
|
||||||
unwanted = true;
|
unwanted = true;
|
||||||
log.vdebug("OneDrive change path is to be excluded by user configuration: ", path);
|
log.vlog("Skipping item - path excluded by user config: ", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1641,7 +1648,7 @@ final class SyncEngine
|
||||||
// If path or filename does not exclude, is this excluded due to use of selective sync?
|
// If path or filename does not exclude, is this excluded due to use of selective sync?
|
||||||
if (!unwanted) {
|
if (!unwanted) {
|
||||||
path = itemdb.computePath(item.driveId, item.id);
|
path = itemdb.computePath(item.driveId, item.id);
|
||||||
unwanted = selectiveSync.isPathExcluded(path);
|
unwanted = selectiveSync.isPathExcludedViaSyncList(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip unwanted items
|
// skip unwanted items
|
||||||
|
@ -2179,12 +2186,20 @@ final class SyncEngine
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selectiveSync.isPathExcluded(path)) {
|
if (selectiveSync.isPathExcludedViaSyncList(path)) {
|
||||||
if ((isFile(path)) && (cfg.getValueBool("sync_root_files")) && (rootName(strip(path,"./")) == "")) {
|
if ((isFile(path)) && (cfg.getValueBool("sync_root_files")) && (rootName(strip(path,"./")) == "")) {
|
||||||
log.vdebug("Not skipping path due to sync_root_files inclusion: ", path);
|
log.vdebug("Not skipping path due to sync_root_files inclusion: ", path);
|
||||||
} else {
|
} else {
|
||||||
log.vlog("Skipping item - path excluded by sync_list: ", path);
|
string userSyncList = cfg.configDirName ~ "/sync_list";
|
||||||
return;
|
if (exists(userSyncList)){
|
||||||
|
// skipped most likely due to inclusion in sync_list
|
||||||
|
log.vlog("Skipping item - excluded by skip_list config: ", path);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// skipped for some other reason
|
||||||
|
log.vlog("Skipping item - path excluded by user config: ", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue