mirror of
https://github.com/rclone/rclone
synced 2024-11-26 04:07:22 +01:00
fs: warn the user when using a remote name without a colon
A very common mistake for new users of rclone is to use a remote name without a colon. This can be on the command line or in the config when setting up a crypt backend. This change checks to see if the user uses a path which matches a remote name and gives an NOTICE like this if they do NOTICE: "remote" refers to a local folder, use "remote:" to refer to your remote or "./remote" to hide this warning See: https://forum.rclone.org/t/sync-to-onedrive-personal-lands-file-in-localfilesystem-but-not-in-onedrive/32956
This commit is contained in:
parent
57803bee22
commit
d3d843a11d
@ -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.
|
||||
//
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user