Use rclone.conf from rclone executable directory if already existing

This commit is contained in:
albertony 2019-06-03 21:14:32 +02:00 committed by Nick Craig-Wood
parent 550ab441c5
commit 976a020a2f
2 changed files with 17 additions and 1 deletions

View File

@ -452,7 +452,11 @@ Specify the location of the rclone config file.
Normally the config file is in your home directory as a file called
`.config/rclone/rclone.conf` (or `.rclone.conf` if created with an
older version). If `$XDG_CONFIG_HOME` is set it will be at
`$XDG_CONFIG_HOME/rclone/rclone.conf`
`$XDG_CONFIG_HOME/rclone/rclone.conf`.
If there is a file `rclone.conf` in the same directory as the rclone
executable it will be preferred. This file must be created manually
for Rclone to use it, it will never be created automatically.
If you run `rclone config file` you will see where the default
location is for you.

View File

@ -105,6 +105,18 @@ func getConfigData() *goconfig.ConfigFile {
// Return the path to the configuration file
func makeConfigPath() string {
// Use rclone.conf from rclone executable directory if already existing
exe, err := os.Executable()
if err == nil {
exedir := filepath.Dir(exe)
cfgpath := filepath.Join(exedir, configFileName)
_, err := os.Stat(cfgpath)
if err == nil {
return cfgpath
}
}
// Find user's home directory
homeDir, err := homedir.Dir()