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: warn the user when using a remote name without a colon

Nick Craig-Woodd3d843a11d4a
diff --git a/fs/config.go b/fs/config.go
index b253a5c30..13d523558 100644
--- a/fs/config.go
+++ b/fs/config.go
@@ -29,6 +29,12 @@ var (
return errors.New("no config file set handler")
}
+ // Check if the config file has the named section
+ //
+ // This is a function pointer to decouple the config
+ // implementation from the fs
+ ConfigFileHasSection = func(section string) bool { return false }
+
// CountError counts an error. If any errors have been
// counted then rclone will exit with a non zero error code.
//
diff --git a/fs/config/config.go b/fs/config/config.go
index 0c84127e6..4a6725237 100644
--- a/fs/config/config.go
+++ b/fs/config/config.go
@@ -117,6 +117,9 @@ func init() {
// Set the function pointers up in fs
fs.ConfigFileGet = FileGetFlag
fs.ConfigFileSet = SetValueAndSave
+ fs.ConfigFileHasSection = func(section string) bool {
+ return LoadedData().HasSection(section)
+ }
configPath = makeConfigPath()
cacheDir = makeCacheDir() // Has fallback to tempDir, so set that first
data = newDefaultStorage()
diff --git a/fs/newfs.go b/fs/newfs.go
index adf8582fa..927d278b4 100644
--- a/fs/newfs.go
+++ b/fs/newfs.go
@@ -26,6 +26,9 @@ import (
// up with drive letters.
func NewFs(ctx context.Context, path string) (Fs, error) {
Debugf(nil, "Creating backend with remote %q", path)
+ if ConfigFileHasSection(path) {
+ Logf(nil, "%q refers to a local folder, use %q to refer to your remote or %q to hide this warning", path, path+":", "./"+path)
+ }
fsInfo, configName, fsPath, config, err := ConfigFs(path)
if err != nil {
return nil, err