From 021f25a748b5665b9f37e4b0ee49d3ca80ebdcc8 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 2 Sep 2023 18:13:42 +0100 Subject: [PATCH] fs: make ConfigFs take an fs.Info which makes it more useful --- fs/newfs.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/newfs.go b/fs/newfs.go index 9be890ec7..6c20814ec 100644 --- a/fs/newfs.go +++ b/fs/newfs.go @@ -117,7 +117,7 @@ func ParseRemote(path string) (fsInfo *RegInfo, configName, fsPath string, conne // configString returns a canonical version of the config string used // to configure the Fs as passed to fs.NewFs -func configString(f Fs, full bool) string { +func configString(f Info, full bool) string { name := f.Name() if open := strings.IndexRune(name, '{'); full && open >= 0 && strings.HasSuffix(name, "}") { suffix := name[open:] @@ -140,10 +140,16 @@ func configString(f Fs, full bool) string { // ConfigString returns a canonical version of the config string used // to configure the Fs as passed to fs.NewFs. For Fs with extra // parameters this will include a canonical {hexstring} suffix. -func ConfigString(f Fs) string { +func ConfigString(f Info) string { return configString(f, false) } +// FullPath returns the full path with remote:path/to/object +// for an object. +func FullPath(o Object) string { + return fspath.JoinRootPath(ConfigString(o.Fs()), o.Remote()) +} + // ConfigStringFull returns a canonical version of the config string // used to configure the Fs as passed to fs.NewFs. This string can be // used to re-instantiate the Fs exactly so includes all the extra