newFsFileAddFilter creates an src Fs from a name This works the same as NewFsFile however it adds filters to the Fs to limit it to a single file if the remote pointed to a file.
(remote string)
| 109 | // This works the same as NewFsFile however it adds filters to the Fs |
| 110 | // to limit it to a single file if the remote pointed to a file. |
| 111 | func newFsFileAddFilter(remote string) (fs.Fs, string) { |
| 112 | ctx := context.Background() |
| 113 | fi := filter.GetConfig(ctx) |
| 114 | f, fileName := NewFsFile(remote) |
| 115 | if fileName != "" { |
| 116 | if !fi.InActive() { |
| 117 | err := fmt.Errorf("can't limit to single files when using filters: %v", remote) |
| 118 | err = fs.CountError(ctx, err) |
| 119 | fs.Fatal(nil, err.Error()) |
| 120 | } |
| 121 | // Limit transfers to this file |
| 122 | err := fi.AddFile(fileName) |
| 123 | if err != nil { |
| 124 | err = fs.CountError(ctx, err) |
| 125 | fs.Fatalf(nil, "Failed to limit to single file %q: %v", remote, err) |
| 126 | } |
| 127 | } |
| 128 | return f, fileName |
| 129 | } |
| 130 | |
| 131 | // NewFsSrc creates a new src fs from the arguments. |
| 132 | // |