mirror of
https://github.com/rclone/rclone
synced 2024-12-02 11:53:45 +01:00
Fix --files-from with an empty file copying everything - fixes #1196
This commit is contained in:
parent
4ab7e05e02
commit
10e532bce9
10
fs/filter.go
10
fs/filter.go
@ -212,6 +212,7 @@ func NewFilter() (f *Filter, err error) {
|
||||
}
|
||||
if filesFrom != nil {
|
||||
for _, rule := range *filesFrom {
|
||||
f.initAddFile() // init to show --files-from set even if no files within
|
||||
err := forEachLine(rule, func(line string) error {
|
||||
return f.AddFile(line)
|
||||
})
|
||||
@ -323,12 +324,17 @@ func (f *Filter) AddRule(rule string) error {
|
||||
return errors.Errorf("malformed rule %q", rule)
|
||||
}
|
||||
|
||||
// AddFile adds a single file to the files from list
|
||||
func (f *Filter) AddFile(file string) error {
|
||||
// initAddFile creates f.files and f.dirs
|
||||
func (f *Filter) initAddFile() {
|
||||
if f.files == nil {
|
||||
f.files = make(FilesMap)
|
||||
f.dirs = make(FilesMap)
|
||||
}
|
||||
}
|
||||
|
||||
// AddFile adds a single file to the files from list
|
||||
func (f *Filter) AddFile(file string) error {
|
||||
f.initAddFile()
|
||||
file = strings.Trim(file, "/")
|
||||
f.files[file] = struct{}{}
|
||||
// Put all the parent directories into f.dirs
|
||||
|
Loading…
Reference in New Issue
Block a user