mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-08 00:42:13 +02:00
* Implement #699 - Perform skip_dir explicit match only
This commit is contained in:
parent
28b37007f2
commit
14cd47b56f
1
config
1
config
|
@ -33,3 +33,4 @@
|
||||||
# classify_as_big_delete = "1000"
|
# classify_as_big_delete = "1000"
|
||||||
# user_agent = ""
|
# user_agent = ""
|
||||||
# remove_source_files = "false"
|
# remove_source_files = "false"
|
||||||
|
# skip_dir_strict_match = "false"
|
|
@ -639,6 +639,8 @@ Options:
|
||||||
Check for the presence of .nosync in the syncdir root. If found, do not perform sync.
|
Check for the presence of .nosync in the syncdir root. If found, do not perform sync.
|
||||||
--check-for-nosync
|
--check-for-nosync
|
||||||
Check for the presence of .nosync in each directory. If found, skip directory from sync.
|
Check for the presence of .nosync in each directory. If found, skip directory from sync.
|
||||||
|
--classify-as-big-delete
|
||||||
|
Number of children in a path that is locally removed which will be classified as a 'big data delete'
|
||||||
--confdir ARG
|
--confdir ARG
|
||||||
Set the directory used to store the configuration files
|
Set the directory used to store the configuration files
|
||||||
--create-directory ARG
|
--create-directory ARG
|
||||||
|
@ -695,12 +697,16 @@ Options:
|
||||||
Print the access token, useful for debugging
|
Print the access token, useful for debugging
|
||||||
--remove-directory ARG
|
--remove-directory ARG
|
||||||
Remove a directory on OneDrive - no sync will be performed.
|
Remove a directory on OneDrive - no sync will be performed.
|
||||||
|
--remove-source-files
|
||||||
|
Remove source file after successful transfer to OneDrive when using --upload-only
|
||||||
--resync
|
--resync
|
||||||
Forget the last saved state, perform a full sync
|
Forget the last saved state, perform a full sync
|
||||||
--single-directory ARG
|
--single-directory ARG
|
||||||
Specify a single local directory within the OneDrive root to sync.
|
Specify a single local directory within the OneDrive root to sync.
|
||||||
--skip-dir
|
--skip-dir ARG
|
||||||
Skip any directories that match this pattern from syncing
|
Skip any directories that match this pattern from syncing
|
||||||
|
--skip-dir-strict-match
|
||||||
|
When matching skip_dir directories, only match explicit matches
|
||||||
--skip-dot-files
|
--skip-dot-files
|
||||||
Skip dot files and folders from syncing
|
Skip dot files and folders from syncing
|
||||||
--skip-file ARG
|
--skip-file ARG
|
||||||
|
|
|
@ -33,6 +33,11 @@ Check for the presence of .nosync in each directory. If found, skip directory fr
|
||||||
.br
|
.br
|
||||||
Configuration file key: \fBcheck_nosync\fP (default: \fBfalse\fP)
|
Configuration file key: \fBcheck_nosync\fP (default: \fBfalse\fP)
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-classify\-as\-big\-delete\fP
|
||||||
|
Number of children in a path that is locally removed which will be classified as a 'big data delete'
|
||||||
|
.br
|
||||||
|
Configuration file key: \fBclassify_as_big_delete\fP (default: \fB1000\fP)
|
||||||
|
.TP
|
||||||
\fB\-\-confdir\fP ARG
|
\fB\-\-confdir\fP ARG
|
||||||
Set the directory used to store the configuration files
|
Set the directory used to store the configuration files
|
||||||
.TP
|
.TP
|
||||||
|
@ -141,9 +146,22 @@ Forget the last saved state, perform a full sync
|
||||||
\fB\-\-remove\-directory\fP ARG
|
\fB\-\-remove\-directory\fP ARG
|
||||||
Remove a directory on OneDrive \- no sync will be performed.
|
Remove a directory on OneDrive \- no sync will be performed.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-remove\-source\-files\fP
|
||||||
|
Remove source file after successful transfer to OneDrive when using \-\-upload-only
|
||||||
|
.br
|
||||||
|
Configuration file key: \fBremove_source_files\fP (default: \fBfalse\fP)
|
||||||
|
.TP
|
||||||
\fB\-\-single\-directory\fP ARG
|
\fB\-\-single\-directory\fP ARG
|
||||||
Specify a single local directory within the OneDrive root to sync.
|
Specify a single local directory within the OneDrive root to sync.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-skip\-dir\fP ARG
|
||||||
|
Skip any directories that match this pattern from syncing
|
||||||
|
.TP
|
||||||
|
\fB\-\-skip\-dir\-strict\-match\fP
|
||||||
|
When matching skip_dir directories, only match explicit matches
|
||||||
|
.br
|
||||||
|
Configuration file key: \fBskip_dir_strict_match\fP (default: \fBfalse\fP)
|
||||||
|
.TP
|
||||||
\fB\-\-skip\-dot\-files\fP
|
\fB\-\-skip\-dot\-files\fP
|
||||||
Skip dot files and folders from syncing
|
Skip dot files and folders from syncing
|
||||||
.br
|
.br
|
||||||
|
|
|
@ -66,6 +66,8 @@ final class Config
|
||||||
longValues["classify_as_big_delete"] = 1000;
|
longValues["classify_as_big_delete"] = 1000;
|
||||||
// Delete source after successful transfer
|
// Delete source after successful transfer
|
||||||
boolValues["remove_source_files"] = false;
|
boolValues["remove_source_files"] = false;
|
||||||
|
// Strict matching for skip_dir
|
||||||
|
boolValues["skip_dir_strict_match"] = false;
|
||||||
|
|
||||||
// Determine the users home directory.
|
// Determine the users home directory.
|
||||||
// Need to avoid using ~ here as expandTilde() below does not interpret correctly when running under init.d or systemd scripts
|
// Need to avoid using ~ here as expandTilde() below does not interpret correctly when running under init.d or systemd scripts
|
||||||
|
@ -169,6 +171,7 @@ final class Config
|
||||||
boolValues["synchronize"] = false;
|
boolValues["synchronize"] = false;
|
||||||
boolValues["force"] = false;
|
boolValues["force"] = false;
|
||||||
boolValues["remove_source_files"] = false;
|
boolValues["remove_source_files"] = false;
|
||||||
|
boolValues["skip_dir_strict_match"] = false;
|
||||||
|
|
||||||
// Application Startup option validation
|
// Application Startup option validation
|
||||||
try {
|
try {
|
||||||
|
@ -290,6 +293,9 @@ final class Config
|
||||||
"skip-size",
|
"skip-size",
|
||||||
"Skip new files larger than this size (in MB)",
|
"Skip new files larger than this size (in MB)",
|
||||||
&longValues["skip_size"],
|
&longValues["skip_size"],
|
||||||
|
"skip-dir-strict-match",
|
||||||
|
"When matching skip_dir directories, only match explicit matches",
|
||||||
|
&boolValues["skip_dir_strict_match"],
|
||||||
"skip-symlinks",
|
"skip-symlinks",
|
||||||
"Skip syncing of symlinks",
|
"Skip syncing of symlinks",
|
||||||
&boolValues["skip_symlinks"],
|
&boolValues["skip_symlinks"],
|
||||||
|
|
|
@ -506,9 +506,16 @@ int main(string[] args)
|
||||||
selectiveSync.load(cfg.syncListFilePath);
|
selectiveSync.load(cfg.syncListFilePath);
|
||||||
|
|
||||||
// Configure skip_dir & skip_file from config entries
|
// Configure skip_dir & skip_file from config entries
|
||||||
|
// skip_dir items
|
||||||
log.vdebug("Configuring skip_dir ...");
|
log.vdebug("Configuring skip_dir ...");
|
||||||
log.vdebug("skip_dir: ", cfg.getValueString("skip_dir"));
|
log.vdebug("skip_dir: ", cfg.getValueString("skip_dir"));
|
||||||
selectiveSync.setDirMask(cfg.getValueString("skip_dir"));
|
selectiveSync.setDirMask(cfg.getValueString("skip_dir"));
|
||||||
|
// Was --skip-dir-strict-match configured?
|
||||||
|
if (cfg.getValueBool("skip_dir_strict_match")) {
|
||||||
|
selectiveSync.setSkipDirStrictMatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip_file items
|
||||||
log.vdebug("Configuring skip_file ...");
|
log.vdebug("Configuring skip_file ...");
|
||||||
// Validate skip_file to ensure that this does not contain an invalid configuration
|
// Validate skip_file to ensure that this does not contain an invalid configuration
|
||||||
// Do not use a skip_file entry of .* as this will prevent correct searching of local changes to process.
|
// Do not use a skip_file entry of .* as this will prevent correct searching of local changes to process.
|
||||||
|
|
|
@ -11,6 +11,7 @@ final class SelectiveSync
|
||||||
private string[] paths;
|
private string[] paths;
|
||||||
private Regex!char mask;
|
private Regex!char mask;
|
||||||
private Regex!char dirmask;
|
private Regex!char dirmask;
|
||||||
|
private bool skipDirStrictMatch = false;
|
||||||
|
|
||||||
void load(string filepath)
|
void load(string filepath)
|
||||||
{
|
{
|
||||||
|
@ -23,6 +24,13 @@ final class SelectiveSync
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Configure skipDirStrictMatch if function is called
|
||||||
|
// By default, skipDirStrictMatch = false;
|
||||||
|
void setSkipDirStrictMatch()
|
||||||
|
{
|
||||||
|
skipDirStrictMatch = true;
|
||||||
|
}
|
||||||
|
|
||||||
void setFileMask(const(char)[] mask)
|
void setFileMask(const(char)[] mask)
|
||||||
{
|
{
|
||||||
this.mask = wild2regex(mask);
|
this.mask = wild2regex(mask);
|
||||||
|
@ -44,12 +52,15 @@ final class SelectiveSync
|
||||||
if (!name.matchFirst(dirmask).empty) {
|
if (!name.matchFirst(dirmask).empty) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// check just the file name
|
// Do we check the base name as well?
|
||||||
|
if (!skipDirStrictMatch) {
|
||||||
|
// check just the basename in the path
|
||||||
string filename = baseName(name);
|
string filename = baseName(name);
|
||||||
if(!filename.matchFirst(dirmask).empty) {
|
if(!filename.matchFirst(dirmask).empty) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// no match
|
// no match
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue