"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
config: Make fs.ConfigFileGet return an exists flag
Nick Craig-Wood3c89406886bc
diff --git a/fs/config.go b/fs/config.goindex c5283e14b..99b83fc26 100644--- a/fs/config.go+++ b/fs/config.go@@ -15,7 +15,7 @@ var (//// This is a function pointer to decouple the config// implementation from the fs- ConfigFileGet = func(section, key string, defaultVal ...string) string { return "" }+ ConfigFileGet = func(section, key string) (string, bool) { return "", false }// CountError counts an error. If any errors have been// counted then it will exit with a non zero error code.diff --git a/fs/config/config.go b/fs/config/config.goindex 4eca15032..1f7e1d531 100644--- a/fs/config/config.go+++ b/fs/config/config.go@@ -82,7 +82,7 @@ var (func init() {// Set the function pointer up in fs- fs.ConfigFileGet = FileGet+ fs.ConfigFileGet = FileGetFlag}func getConfigData() *goconfig.ConfigFile {@@ -1108,6 +1108,19 @@ func Authorize(args []string) {fs.Config(name)}+// FileGetFlag gets the config key under section returning the+// the value and true if found and or ("", false) otherwise+//+// It looks up defaults in the environment if they are present+func FileGetFlag(section, key string) (string, bool) {+ newValue, err := getConfigData().GetValue(section, key)+ if err == nil {+ return newValue, true+ }+ envKey := fs.ConfigToEnv(section, key)+ return os.LookupEnv(envKey)+}+// FileGet gets the config key under section returning the// default or empty string if not set.//diff --git a/fs/fs.go b/fs/fs.goindex 5154e9a76..793b20bd6 100644--- a/fs/fs.go+++ b/fs/fs.go@@ -790,9 +790,10 @@ func MustFind(name string) *RegInfo {func ParseRemote(path string) (fsInfo *RegInfo, configName, fsPath string, err error) {configName, fsPath = fspath.Parse(path)var fsName string+ var ok boolif configName != "" {- fsName = ConfigFileGet(configName, "type")- if fsName == "" {+ fsName, ok = ConfigFileGet(configName, "type")+ if !ok {return nil, "", "", ErrorNotFoundInConfigFile}} else {