mirror of
https://github.com/abraunegg/onedrive
synced 2024-04-28 04:03:03 +02:00
Support sync_list matching full path root wildcard with exclusions to simplify sync_list configuration (#1273)
* Support sync_list matching full path root wildcard with exclusions to simplify sync_list configuration
This commit is contained in:
parent
cd7b7b0b68
commit
42b7945d9c
|
@ -517,12 +517,18 @@ Each line of the file represents a relative path from your `sync_dir`. All files
|
|||
Here is an example of `sync_list`:
|
||||
```text
|
||||
# sync_list supports comments
|
||||
#
|
||||
# The ordering of entries is highly recommended - exclusions before inclusions
|
||||
#
|
||||
# Exclude temp folders under Documents
|
||||
!Documents/temp*
|
||||
# Exclude my secret data
|
||||
!/Secret_data/*
|
||||
#
|
||||
# Include my Backup folder
|
||||
Backup
|
||||
# Include Documents folder
|
||||
Documents/
|
||||
# Exclude temp folders under Documents
|
||||
!Documents/temp*
|
||||
# Include all PDF documents
|
||||
Documents/*.pdf
|
||||
# Include this single document
|
||||
|
@ -542,6 +548,21 @@ The following are supported for pattern matching and exclusion rules:
|
|||
* Use the `*` to wildcard select any characters to match for the item to be included
|
||||
* Use either `!` or `-` characters at the start of the line to exclude an otherwise included item
|
||||
|
||||
To simplify 'exclusions' and 'inclusions', the following is also possible:
|
||||
```text
|
||||
# sync_list supports comments
|
||||
#
|
||||
# The ordering of entries is highly recommended - exclusions before inclusions
|
||||
#
|
||||
# Exclude temp folders under Documents
|
||||
!Documents/temp*
|
||||
# Exclude my secret data
|
||||
!/Secret_data/*
|
||||
#
|
||||
# Include everything else
|
||||
/*
|
||||
```
|
||||
|
||||
**Note:** After changing the sync_list, you must perform a full re-synchronization by adding `--resync` to your existing command line - for example: `onedrive --synchronize --resync`
|
||||
|
||||
**Note:** In some circumstances, it may be required to sync all the individual files within the 'sync_dir', but due to frequent name change / addition / deletion of these files, it is not desirable to constantly change the 'sync_list' file to include / exclude these files and force a resync. To assist with this, enable the following in your configuration file:
|
||||
|
|
|
@ -213,7 +213,8 @@ private bool isPathExcluded(string path, string[] allowedPaths)
|
|||
{
|
||||
// function variables
|
||||
bool exclude = false;
|
||||
bool finalResult = true; // will get updated to false, if pattern matched to sync_list entry
|
||||
bool excludeMatched = false; // will get updated to true, if there is a pattern match to sync_list entry
|
||||
bool finalResult = true; // will get updated to false, if pattern match to sync_list entry
|
||||
int offset;
|
||||
string wildcard = "*";
|
||||
|
||||
|
@ -283,6 +284,7 @@ private bool isPathExcluded(string path, string[] allowedPaths)
|
|||
} else {
|
||||
log.vdebug("Evaluation against 'sync_list' result: direct match but to be excluded");
|
||||
finalResult = true;
|
||||
// do not set excludeMatched = true here, otherwise parental path also gets excluded
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -295,6 +297,7 @@ private bool isPathExcluded(string path, string[] allowedPaths)
|
|||
} else {
|
||||
log.vdebug("Evaluation against 'sync_list' result: parental path match but must be excluded");
|
||||
finalResult = true;
|
||||
excludeMatched = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,11 +309,13 @@ private bool isPathExcluded(string path, string[] allowedPaths)
|
|||
auto allowedMask = regex(regexCompatiblePath);
|
||||
if (matchAll(path, allowedMask)) {
|
||||
// regex wildcard evaluation matches
|
||||
if (!exclude) {
|
||||
// if we have a prior pattern match for an exclude, excludeMatched = true
|
||||
if (!exclude && !excludeMatched) {
|
||||
// nothing triggered an exclusion before evaluation against wildcard match attempt
|
||||
log.vdebug("Evaluation against 'sync_list' result: wildcard pattern match");
|
||||
finalResult = false;
|
||||
} else {
|
||||
log.vdebug("Evaluation against 'sync_list' result: wildcard pattern match but to be excluded");
|
||||
log.vdebug("Evaluation against 'sync_list' result: wildcard pattern matched but must be excluded");
|
||||
finalResult = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue