-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change(rclone): build --filter based on include/excludes set on the c…
…heck
- Loading branch information
Showing
3 changed files
with
30 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package rclone | ||
|
||
import "fmt" | ||
|
||
func IncludeExcludeToFilters(includes []string, excludes []string) []string { | ||
params := make([]string, 0) | ||
|
||
// add excludes | ||
if len(excludes) > 0 { | ||
for _, exclude := range excludes { | ||
params = append(params, "--filter", fmt.Sprintf("- %s", exclude)) | ||
} | ||
} | ||
|
||
// were there includes? | ||
if len(includes) > 0 { | ||
for _, include := range includes { | ||
params = append(params, "--filter", fmt.Sprintf("+ %s", include)) | ||
} | ||
|
||
// includes need the below, see: https://forum.rclone.org/t/filter-or-include-exclude-help-needed/10890/2 | ||
params = append(params, "--filter", "- *") | ||
} | ||
|
||
return params | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters