Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fs: Implement RegInfo.FileName to return the on disk filename for a backend

Nick Craig-Wood6b1f915ebccd
diff --git a/bin/make_backend_docs.py b/bin/make_backend_docs.py
index 79934c2e9..83db62366 100755
--- a/bin/make_backend_docs.py
+++ b/bin/make_backend_docs.py
@@ -10,19 +10,12 @@ marker = "<!--- autogenerated options"
start = marker + " start"
stop = marker + " stop"
-# directory name to backend name
-dir_to_backend = {
- "googlecloudstorage": "google cloud storage",
- "amazonclouddrive": "amazon cloud drive",
-}
-
def find_backends():
"""Return a list of all backends"""
return [ x for x in os.listdir("backend") if x not in ("all",) ]
def output_docs(backend, out):
"""Output documentation for backend options to out"""
- backend = dir_to_backend.get(backend, backend)
out.flush()
subprocess.check_call(["rclone", "help", "backend", backend], stdout=out)
diff --git a/fs/fs.go b/fs/fs.go
index ec6d1e267..6a3b3a282 100644
--- a/fs/fs.go
+++ b/fs/fs.go
@@ -83,6 +83,11 @@ type RegInfo struct {
Options Options
}
+// FileName returns the on disk file name for this backend
+func (ri *RegInfo) FileName() string {
+ return strings.Replace(ri.Name, " ", "", -1)
+}
+
// Options is a slice of configuration Option for a backend
type Options []Option
@@ -871,7 +876,7 @@ type ObjectPair struct {
// Services are looked up in the config file
func Find(name string) (*RegInfo, error) {
for _, item := range Registry {
- if item.Name == name || item.Prefix == name {
+ if item.Name == name || item.Prefix == name || item.FileName() == name {
return item, nil
}
}