cache: export Canonicalize method for external use
This commit is contained in:
parent
79f5d940cf
commit
ae8bbc63da
1 changed files with 4 additions and 4 deletions
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
|
remap = map[string]string{} // map user supplied names to canonical names
|
||||||
)
|
)
|
||||||
|
|
||||||
// Lookup fsString in the mapping from user supplied names to
|
// Canonicalize looks up fsString in the mapping from user supplied
|
||||||
// canonical names and return the canonical form
|
// names to canonical names and return the canonical form
|
||||||
func canonicalize(fsString string) string {
|
func Canonicalize(fsString string) string {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
canonicalName, ok := remap[fsString]
|
canonicalName, ok := remap[fsString]
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
|
@ -40,7 +40,7 @@ func addMapping(fsString, canonicalName string) {
|
||||||
// GetFn gets an fs.Fs named fsString either from the cache or creates
|
// GetFn gets an fs.Fs named fsString either from the cache or creates
|
||||||
// it afresh with the create function
|
// it afresh with the create function
|
||||||
func GetFn(fsString string, create func(fsString string) (fs.Fs, error)) (f fs.Fs, err error) {
|
func GetFn(fsString string, create func(fsString string) (fs.Fs, error)) (f fs.Fs, err error) {
|
||||||
fsString = canonicalize(fsString)
|
fsString = Canonicalize(fsString)
|
||||||
created := false
|
created := false
|
||||||
value, err := c.Get(fsString, func(fsString string) (f interface{}, ok bool, err error) {
|
value, err := c.Get(fsString, func(fsString string) (f interface{}, ok bool, err error) {
|
||||||
f, err = create(fsString)
|
f, err = create(fsString)
|
||||||
|
|
Loading…
Add table
Reference in a new issue