mirror of https://github.com/rclone/rclone.git
config: treat any config file paths with filename notfound as memory-only config (#5235)
This commit is contained in:
parent
b456be4303
commit
3544e09e95
|
@ -686,8 +686,8 @@ to run in "portable" mode by downloading rclone executable to a
|
||||||
writable directory and then create an empty file `rclone.conf` in the
|
writable directory and then create an empty file `rclone.conf` in the
|
||||||
same directory.
|
same directory.
|
||||||
|
|
||||||
If the location is set to empty string `""` or the special value
|
If the location is set to empty string `""` or path to a file
|
||||||
`/notfound`, or the os null device represented by value `NUL` on
|
with name `notfound`, or the os null device represented by value `NUL` on
|
||||||
Windows and `/dev/null` on Unix systems, then rclone will keep the
|
Windows and `/dev/null` on Unix systems, then rclone will keep the
|
||||||
config file in memory only.
|
config file in memory only.
|
||||||
|
|
||||||
|
@ -1920,11 +1920,12 @@ Nevertheless, rclone will read any configuration file found
|
||||||
according to the rules described [above](https://rclone.org/docs/#config-config-file).
|
according to the rules described [above](https://rclone.org/docs/#config-config-file).
|
||||||
If an encrypted configuration file is found, this means you will be prompted for
|
If an encrypted configuration file is found, this means you will be prompted for
|
||||||
password (unless using `--password-command`). To avoid this, you can bypass
|
password (unless using `--password-command`). To avoid this, you can bypass
|
||||||
the loading of the configuration file by overriding the location with an empty
|
the loading of the default configuration file by overriding the location,
|
||||||
string `""` or the special value `/notfound`, or the os null device represented
|
e.g. with one of the documented special values for memory-only configuration:
|
||||||
by value `NUL` on Windows and `/dev/null` on Unix systems (before rclone
|
|
||||||
version 1.55 only this null device alternative was supported).
|
```
|
||||||
E.g. `rclone --config="" genautocomplete bash`.
|
rclone genautocomplete bash --config=""
|
||||||
|
```
|
||||||
|
|
||||||
Developer options
|
Developer options
|
||||||
-----------------
|
-----------------
|
||||||
|
|
|
@ -29,7 +29,7 @@ import (
|
||||||
const (
|
const (
|
||||||
configFileName = "rclone.conf"
|
configFileName = "rclone.conf"
|
||||||
hiddenConfigFileName = "." + configFileName
|
hiddenConfigFileName = "." + configFileName
|
||||||
noConfigFile = "/notfound"
|
noConfigFile = "notfound"
|
||||||
|
|
||||||
// ConfigToken is the key used to store the token under
|
// ConfigToken is the key used to store the token under
|
||||||
ConfigToken = "token"
|
ConfigToken = "token"
|
||||||
|
@ -113,16 +113,12 @@ var (
|
||||||
Password = random.Password
|
Password = random.Password
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var configPath string
|
||||||
configPath string
|
|
||||||
noConfigPath string
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Set the function pointers up in fs
|
// Set the function pointers up in fs
|
||||||
fs.ConfigFileGet = FileGetFlag
|
fs.ConfigFileGet = FileGetFlag
|
||||||
fs.ConfigFileSet = SetValueAndSave
|
fs.ConfigFileSet = SetValueAndSave
|
||||||
noConfigPath, _ = filepath.Abs(noConfigFile)
|
|
||||||
configPath = makeConfigPath()
|
configPath = makeConfigPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,16 +316,13 @@ func SetConfigPath(path string) (err error) {
|
||||||
var cfgPath string
|
var cfgPath string
|
||||||
if path == "" || path == os.DevNull {
|
if path == "" || path == os.DevNull {
|
||||||
cfgPath = ""
|
cfgPath = ""
|
||||||
|
} else if filepath.Base(path) == noConfigFile {
|
||||||
|
cfgPath = ""
|
||||||
} else if err = file.IsReserved(path); err != nil {
|
} else if err = file.IsReserved(path); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else if cfgPath, err = filepath.Abs(path); err != nil {
|
||||||
if cfgPath, err = filepath.Abs(path); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if cfgPath == noConfigPath {
|
|
||||||
cfgPath = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
configPath = cfgPath
|
configPath = cfgPath
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue