mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-10 09:46:40 +02:00
* Add ability to skip symlinks
This commit is contained in:
parent
8c2629e90c
commit
c0074638da
|
@ -194,6 +194,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_symlinks`: any files or directories that are symlinked will be skipped during sync
|
||||
|
||||
### sync_dir
|
||||
Example: `sync_dir="~/MyDirToSync"`
|
||||
|
@ -210,6 +211,11 @@ Patterns are case insensitive. `*` and `?` [wildcards characters](https://techne
|
|||
|
||||
**Note:** after changing `skip_file`, you must perform a full synchronization by executing `onedrive --resync`
|
||||
|
||||
### skip_symlinks
|
||||
Example: `skip_symlinks = "true"`
|
||||
|
||||
Setting this to `"true"` will skip all symlinks while syncing.
|
||||
|
||||
### Selective sync
|
||||
Selective sync allows you to sync only specific files and directories.
|
||||
To enable selective sync create a file named `sync_list` in `~/.config/onedrive`.
|
||||
|
|
|
@ -30,6 +30,9 @@ final class Config
|
|||
// Configure to skip ONLY temp files (~*.doc etc) by default
|
||||
// Prior configuration was: .*|~*
|
||||
setValue("skip_file", "~*");
|
||||
// By default symlinks are not skipped (using string type
|
||||
// instead of boolean because hashmap only stores string types)
|
||||
setValue("skip_symlinks", "false");
|
||||
if (!load(userConfigFilePath)) {
|
||||
log.vlog("No config file found, using defaults");
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ int main(string[] args)
|
|||
bool uploadOnly;
|
||||
// Add a check mounts option to resolve https://github.com/abraunegg/onedrive/issues/8
|
||||
bool checkMount;
|
||||
// Add option to skip symlinks
|
||||
bool skipSymlinks;
|
||||
|
||||
try {
|
||||
auto opt = getopt(
|
||||
|
@ -77,6 +79,7 @@ int main(string[] args)
|
|||
"resync", "Forget the last saved state, perform a full sync", &resync,
|
||||
"remove-directory", "Remove a directory on OneDrive - no sync will be performed.", &removeDirectory,
|
||||
"single-directory", "Specify a single local directory within the OneDrive root to sync.", &singleDirectory,
|
||||
"skip-symlinks", "Skip syncing of symlinks", &skipSymlinks,
|
||||
"source-directory", "Source directory to rename or move on OneDrive - no sync will be performed.", &sourceDirectory,
|
||||
"syncdir", "Set the directory used to sync the files that are synced", &syncDirName,
|
||||
"synchronize", "Perform a synchronization", &synchronize,
|
||||
|
@ -119,6 +122,7 @@ int main(string[] args)
|
|||
|
||||
// command line parameters override the config
|
||||
if (syncDirName) cfg.setValue("sync_dir", syncDirName.expandTilde().absolutePath());
|
||||
if (skipSymlinks) cfg.setValue("skip_symlinks", "true");
|
||||
|
||||
// upgrades
|
||||
if (exists(configDirName ~ "/items.db")) {
|
||||
|
|
16
src/sync.d
16
src/sync.d
|
@ -933,10 +933,18 @@ final class SyncEngine
|
|||
if(encodeComponent(path).length < maxPathLength){
|
||||
// path is less than maxPathLength
|
||||
|
||||
// skip unexisting symbolic links
|
||||
if (isSymlink(path) && !exists(readLink(path))) {
|
||||
log.vlog("Skipping item - symbolic link: ", path);
|
||||
return;
|
||||
if (isSymlink(path)) {
|
||||
// if config says so we skip all symlinked items
|
||||
if (cfg.getValue("skip_symlinks") == "true") {
|
||||
log.vlog("Skipping item - skip symbolic links configured: ", path);
|
||||
return;
|
||||
|
||||
}
|
||||
// skip unexisting symbolic links
|
||||
else if (!exists(readLink(path))) {
|
||||
log.vlog("Skipping item - invalid symbolic link: ", path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Restriction and limitations about windows naming files
|
||||
|
|
Loading…
Reference in a new issue