mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-03 14:32:24 +02:00
Merge branch 'master' into norbert/config-options
This commit is contained in:
commit
a71b9bf789
13
README.md
13
README.md
|
@ -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:
|
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:**
|
**Invalid configuration:**
|
||||||
```
|
```text
|
||||||
skip_file = "= .*|~*"
|
skip_file = "= .*|~*"
|
||||||
```
|
```
|
||||||
**Minimum valid configuration:**
|
**Minimum valid configuration:**
|
||||||
```
|
```text
|
||||||
skip_file = "~*"
|
skip_file = "~*"
|
||||||
```
|
```
|
||||||
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.
|
||||||
|
@ -265,6 +265,7 @@ Config path = /home/alex/.config/onedrive
|
||||||
Config file found in config path = false
|
Config file found in config path = false
|
||||||
Config option 'sync_dir' = /home/alex/OneDrive
|
Config option 'sync_dir' = /home/alex/OneDrive
|
||||||
Config option 'skip_file' = ~*
|
Config option 'skip_file' = ~*
|
||||||
|
Config option 'skip_dotfiles' = false
|
||||||
Config option 'skip_symlinks' = false
|
Config option 'skip_symlinks' = false
|
||||||
Config option 'monitor_interval' = 45
|
Config option 'monitor_interval' = 45
|
||||||
Config option 'min_notif_changes' = 5
|
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:
|
Available options:
|
||||||
* `sync_dir`: directory where the files will be synced
|
* `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_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
|
* `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
|
* `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
|
* `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.
|
**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
|
### skip_symlinks
|
||||||
Example: `skip_symlinks = "true"`
|
Example: `skip_symlinks = "true"`
|
||||||
|
|
||||||
|
@ -619,6 +626,8 @@ Options:
|
||||||
Remove a directory on OneDrive - no sync will be performed.
|
Remove a directory on OneDrive - no sync will be performed.
|
||||||
--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-dot-files
|
||||||
|
Skip dot files and folders from syncing
|
||||||
--skip-symlinks
|
--skip-symlinks
|
||||||
Skip syncing of symlinks
|
Skip syncing of symlinks
|
||||||
--source-directory ARG
|
--source-directory ARG
|
||||||
|
|
|
@ -23,4 +23,12 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown "${oduser}:${odgroup}" /onedrive/ /onedrive/conf
|
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[@]}"
|
||||||
|
|
|
@ -81,6 +81,9 @@ Remove a directory on OneDrive \- no sync will be performed.
|
||||||
\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\-dot\-files\fP
|
||||||
|
Skip dot files and folders from syncing
|
||||||
|
.TP
|
||||||
\fB\-\-skip\-symlinks\fP
|
\fB\-\-skip\-symlinks\fP
|
||||||
Skip syncing of symlinks
|
Skip syncing of symlinks
|
||||||
.TP
|
.TP
|
||||||
|
|
|
@ -40,6 +40,7 @@ final class Config
|
||||||
boolValues["no_remote_delete"] = false;
|
boolValues["no_remote_delete"] = false;
|
||||||
boolValues["skip_symlinks"] = false;
|
boolValues["skip_symlinks"] = false;
|
||||||
boolValues["debug_https"] = false;
|
boolValues["debug_https"] = false;
|
||||||
|
boolValues["skip_dotfiles"] = false;
|
||||||
longValues["verbose"] = 0;
|
longValues["verbose"] = 0;
|
||||||
longValues["monitor_interval"] = 45,
|
longValues["monitor_interval"] = 45,
|
||||||
longValues["min_notif_changes"] = 5;
|
longValues["min_notif_changes"] = 5;
|
||||||
|
@ -179,6 +180,9 @@ final class Config
|
||||||
"no-remote-delete",
|
"no-remote-delete",
|
||||||
"Do not delete local file 'deletes' from OneDrive when using --upload-only",
|
"Do not delete local file 'deletes' from OneDrive when using --upload-only",
|
||||||
&boolValues["no_remote_delete"],
|
&boolValues["no_remote_delete"],
|
||||||
|
"skip-dot-files",
|
||||||
|
"Skip dot files and folders from syncing",
|
||||||
|
&boolValues["skip_dotfiles"],
|
||||||
"skip-symlinks",
|
"skip-symlinks",
|
||||||
"Skip syncing of symlinks",
|
"Skip syncing of symlinks",
|
||||||
&boolValues["skip_symlinks"],
|
&boolValues["skip_symlinks"],
|
||||||
|
|
|
@ -68,7 +68,6 @@ int main(string[] args)
|
||||||
// Are we able to reach the OneDrive Service
|
// Are we able to reach the OneDrive Service
|
||||||
bool online = false;
|
bool online = false;
|
||||||
|
|
||||||
|
|
||||||
// sync_dir environment handling to handle ~ expansion properly
|
// sync_dir environment handling to handle ~ expansion properly
|
||||||
string syncDir;
|
string syncDir;
|
||||||
if ((environment.get("SHELL") == "") && (environment.get("USER") == "")){
|
if ((environment.get("SHELL") == "") && (environment.get("USER") == "")){
|
||||||
|
@ -145,6 +144,7 @@ int main(string[] args)
|
||||||
// Config Options
|
// Config Options
|
||||||
writeln("Config option 'sync_dir' = ", syncDir);
|
writeln("Config option 'sync_dir' = ", syncDir);
|
||||||
writeln("Config option 'skip_file' = ", cfg.getValueString("skip_file"));
|
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 'skip_symlinks' = ", cfg.getValueBool("skip_symlinks"));
|
||||||
writeln("Config option 'monitor_interval' = ", cfg.getValueLong("monitor_interval"));
|
writeln("Config option 'monitor_interval' = ", cfg.getValueLong("monitor_interval"));
|
||||||
writeln("Config option 'min_notif_changes' = ", cfg.getValueLong("min_notif_changes"));
|
writeln("Config option 'min_notif_changes' = ", cfg.getValueLong("min_notif_changes"));
|
||||||
|
|
33
src/sync.d
33
src/sync.d
|
@ -75,6 +75,21 @@ private bool hasId(const ref JSONValue item)
|
||||||
return ("id" in item) != null;
|
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
|
// construct an Item struct from a JSON driveItem
|
||||||
private Item makeItem(const ref JSONValue driveItem)
|
private Item makeItem(const ref JSONValue driveItem)
|
||||||
{
|
{
|
||||||
|
@ -767,6 +782,14 @@ final class SyncEngine
|
||||||
unwanted = true;
|
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
|
// skip unwanted items early
|
||||||
if (unwanted) {
|
if (unwanted) {
|
||||||
|
@ -1311,7 +1334,15 @@ final class SyncEngine
|
||||||
|
|
||||||
if(path.byGrapheme.walkLength < maxPathLength){
|
if(path.byGrapheme.walkLength < maxPathLength){
|
||||||
// path is less than 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 (isSymlink(path)) {
|
||||||
// if config says so we skip all symlinked items
|
// if config says so we skip all symlinked items
|
||||||
if (cfg.getValueBool("skip_symlinks")) {
|
if (cfg.getValueBool("skip_symlinks")) {
|
||||||
|
|
Loading…
Reference in a new issue