Get gets an fs.Fs named fsString either from the cache or creates it afresh
(ctx context.Context, fsString string)
| 173 | |
| 174 | // Get gets an fs.Fs named fsString either from the cache or creates it afresh |
| 175 | func Get(ctx context.Context, fsString string) (f fs.Fs, err error) { |
| 176 | // If we are making a long lived backend which lives longer |
| 177 | // than this request, we want to disconnect it from the |
| 178 | // current context and in particular any WithCancel contexts, |
| 179 | // but we want to preserve the config embedded in the context. |
| 180 | newCtx := context.Background() |
| 181 | newCtx = fs.CopyConfig(newCtx, ctx) |
| 182 | newCtx = filter.CopyConfig(newCtx, ctx) |
| 183 | f, err = GetFn(newCtx, fsString, fs.NewFs) |
| 184 | if f == nil || (err != nil && err != fs.ErrorIsFile) { |
| 185 | return f, err |
| 186 | } |
| 187 | // If this is part of an rc job then pin the backend until it finishes |
| 188 | if JobOnFinish != nil && JobGetJobID != nil { |
| 189 | if jobID, ok := JobGetJobID(ctx); ok { |
| 190 | // fs.Debugf(f, "Pin for job %d", jobID) |
| 191 | Pin(f) |
| 192 | _, _ = JobOnFinish(jobID, func() { |
| 193 | // fs.Debugf(f, "Unpin for job %d", jobID) |
| 194 | Unpin(f) |
| 195 | }) |
| 196 | } |
| 197 | } |
| 198 | return f, err |
| 199 | } |
| 200 | |
| 201 | // GetArr gets []fs.Fs from []fsStrings either from the cache or creates it afresh |
| 202 | func GetArr(ctx context.Context, fsStrings []string) (f []fs.Fs, err error) { |