From ca1856724ce118955c91d47306dc06d455341c07 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 1 May 2020 11:51:38 +0100 Subject: [PATCH] fs: add ConfigString function to return a canonical config string --- fs/fs.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/fs.go b/fs/fs.go index 2e4a18d8e..93dc2e38c 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -1331,6 +1331,17 @@ func NewFs(path string) (Fs, error) { return fsInfo.NewFs(configName, fsPath, config) } +// ConfigString returns a canonical version of the config string used +// to configure the Fs as passed to fs.NewFs +func ConfigString(f Fs) string { + name := f.Name() + root := f.Root() + if name == "local" && f.Features().IsLocal { + return root + } + return name + ":" + root +} + // TemporaryLocalFs creates a local FS in the OS's temporary directory. // // No cleanup is performed, the caller must call Purge on the Fs themselves.