fs/cache: add PutErr to add an fs.Fs with an fs.ErrorIsFile error to the cache

This commit is contained in:
Nick Craig-Wood
2024-01-19 10:34:03 +00:00
parent e3f6f68885
commit 5994fcfed8
2 changed files with 37 additions and 4 deletions

11
fs/cache/cache.go vendored
View File

@@ -168,14 +168,19 @@ func GetArr(ctx context.Context, fsStrings []string) (f []fs.Fs, err error) {
return fArr, nil
}
// Put puts an fs.Fs named fsString into the cache
func Put(fsString string, f fs.Fs) {
// PutErr puts an fs.Fs named fsString into the cache with err
func PutErr(fsString string, f fs.Fs, err error) {
createOnFirstUse()
canonicalName := fs.ConfigString(f)
c.Put(canonicalName, f)
c.PutErr(canonicalName, f, err)
addMapping(fsString, canonicalName)
}
// Put puts an fs.Fs named fsString into the cache
func Put(fsString string, f fs.Fs) {
PutErr(fsString, f, nil)
}
// ClearConfig deletes all entries which were based on the config name passed in
//
// Returns number of entries deleted