mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 11:58:20 +08:00
cache: export Canonicalize method for external use
This commit is contained in:
parent
79f5d940cf
commit
ae8bbc63da
8
fs/cache/cache.go
vendored
8
fs/cache/cache.go
vendored
|
@ -14,9 +14,9 @@ var (
|
|||
remap = map[string]string{} // map user supplied names to canonical names
|
||||
)
|
||||
|
||||
// Lookup fsString in the mapping from user supplied names to
|
||||
// canonical names and return the canonical form
|
||||
func canonicalize(fsString string) string {
|
||||
// Canonicalize looks up fsString in the mapping from user supplied
|
||||
// names to canonical names and return the canonical form
|
||||
func Canonicalize(fsString string) string {
|
||||
mu.Lock()
|
||||
canonicalName, ok := remap[fsString]
|
||||
mu.Unlock()
|
||||
|
@ -40,7 +40,7 @@ func addMapping(fsString, canonicalName string) {
|
|||
// GetFn gets an fs.Fs named fsString either from the cache or creates
|
||||
// it afresh with the create function
|
||||
func GetFn(fsString string, create func(fsString string) (fs.Fs, error)) (f fs.Fs, err error) {
|
||||
fsString = canonicalize(fsString)
|
||||
fsString = Canonicalize(fsString)
|
||||
created := false
|
||||
value, err := c.Get(fsString, func(fsString string) (f interface{}, ok bool, err error) {
|
||||
f, err = create(fsString)
|
||||
|
|
Loading…
Reference in New Issue
Block a user