Merge branch 'master' into norbert/config-options

This commit is contained in:
Norbert Preining 2019-02-24 16:07:03 +09:00
commit a71b9bf789
6 changed files with 60 additions and 5 deletions

View file

@ -237,11 +237,11 @@ The 'skilion' version contains a significant number of defect's in how the local
Additionally, if you are using a 'config' file within your configuration directory (`~/.config/onedrive/`), please ensure that you update the `skip_file = ` option as per below:
**Invalid configuration:**
```
```text
skip_file = "= .*|~*"
```
**Minimum valid configuration:**
```
```text
skip_file = "~*"
```
Do not use a skip_file entry of `.*` as this will prevent correct searching of local changes to process.
@ -265,6 +265,7 @@ Config path = /home/alex/.config/onedrive
Config file found in config path = false
Config option 'sync_dir' = /home/alex/OneDrive
Config option 'skip_file' = ~*
Config option 'skip_dotfiles' = false
Config option 'skip_symlinks' = false
Config option 'monitor_interval' = 45
Config option 'min_notif_changes' = 5
@ -395,6 +396,7 @@ This file does not get created by default, and should only be created if you wan
Available options:
* `sync_dir`: directory where the files will be synced
* `skip_file`: any files or directories that match this pattern will be skipped during sync
* `skip_dotfiles`: skip any .files or .folders during sync
* `skip_symlinks`: any files or directories that are symlinked will be skipped during sync
* `monitor_interval`: time interval in seconds by which the monitor process will process local and remote changes
* `min_notif_changes`: minimum number of pending incoming changes to trigger a desktop notification
@ -416,6 +418,11 @@ Patterns are case insensitive. `*` and `?` [wildcards characters](https://techne
**Note:** Do not use a skip_file entry of `.*` as this will prevent correct searching of local changes to process.
### skip_dotfiles
Example: `skip_dotfiles = "true"`
Setting this to `"true"` will skip all .files and .folders while syncing.
### skip_symlinks
Example: `skip_symlinks = "true"`
@ -619,6 +626,8 @@ Options:
Remove a directory on OneDrive - no sync will be performed.
--single-directory ARG
Specify a single local directory within the OneDrive root to sync.
--skip-dot-files
Skip dot files and folders from syncing
--skip-symlinks
Skip syncing of symlinks
--source-directory ARG

View file

@ -23,4 +23,12 @@ else
fi
chown "${oduser}:${odgroup}" /onedrive/ /onedrive/conf
exec gosu "${oduser}" /usr/local/bin/onedrive --monitor --verbose --confdir /onedrive/conf --syncdir /onedrive/data
# Default parameters
ARGS=(--monitor --verbose --confdir /onedrive/conf --syncdir /onedrive/data)
if [ ${#} -gt 0 ]; then
ARGS=("${@}")
fi
exec gosu "${oduser}" /usr/local/bin/onedrive "${ARGS[@]}"

View file

@ -81,6 +81,9 @@ Remove a directory on OneDrive \- no sync will be performed.
\fB\-\-single\-directory\fP ARG
Specify a single local directory within the OneDrive root to sync.
.TP
\fB\-\-skip\-dot\-files\fP
Skip dot files and folders from syncing
.TP
\fB\-\-skip\-symlinks\fP
Skip syncing of symlinks
.TP

View file

@ -40,6 +40,7 @@ final class Config
boolValues["no_remote_delete"] = false;
boolValues["skip_symlinks"] = false;
boolValues["debug_https"] = false;
boolValues["skip_dotfiles"] = false;
longValues["verbose"] = 0;
longValues["monitor_interval"] = 45,
longValues["min_notif_changes"] = 5;
@ -179,6 +180,9 @@ final class Config
"no-remote-delete",
"Do not delete local file 'deletes' from OneDrive when using --upload-only",
&boolValues["no_remote_delete"],
"skip-dot-files",
"Skip dot files and folders from syncing",
&boolValues["skip_dotfiles"],
"skip-symlinks",
"Skip syncing of symlinks",
&boolValues["skip_symlinks"],

View file

@ -68,7 +68,6 @@ int main(string[] args)
// Are we able to reach the OneDrive Service
bool online = false;
// sync_dir environment handling to handle ~ expansion properly
string syncDir;
if ((environment.get("SHELL") == "") && (environment.get("USER") == "")){
@ -145,6 +144,7 @@ int main(string[] args)
// Config Options
writeln("Config option 'sync_dir' = ", syncDir);
writeln("Config option 'skip_file' = ", cfg.getValueString("skip_file"));
writeln("Config option 'skip_dotfiles' = ", cfg.getValueBool("skip_dotfiles"));
writeln("Config option 'skip_symlinks' = ", cfg.getValueBool("skip_symlinks"));
writeln("Config option 'monitor_interval' = ", cfg.getValueLong("monitor_interval"));
writeln("Config option 'min_notif_changes' = ", cfg.getValueLong("min_notif_changes"));

View file

@ -75,6 +75,21 @@ private bool hasId(const ref JSONValue item)
return ("id" in item) != null;
}
private bool isDotFile(string path)
{
// always allow the root
if (path == ".") return false;
path = buildNormalizedPath(path);
auto paths = pathSplitter(path);
foreach(base; paths) {
if (startsWith(base, ".")){
return true;
}
}
return false;
}
// construct an Item struct from a JSON driveItem
private Item makeItem(const ref JSONValue driveItem)
{
@ -767,6 +782,14 @@ final class SyncEngine
unwanted = true;
}
}
// skip downloading dot files if configured
if (cfg.getValueBool("skip_dotfiles")) {
if (isDotFile(path)) {
log.vlog("Skipping item - .file or .folder: ", path);
unwanted = true;
}
}
// skip unwanted items early
if (unwanted) {
@ -1311,7 +1334,15 @@ final class SyncEngine
if(path.byGrapheme.walkLength < maxPathLength){
// path is less than maxPathLength
// skip dot files if configured
if (cfg.getValueBool("skip_dotfiles")) {
if (isDotFile(path)) {
log.vlog("Skipping item - .file or .folder: ", path);
return;
}
}
if (isSymlink(path)) {
// if config says so we skip all symlinked items
if (cfg.getValueBool("skip_symlinks")) {