"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
fs/config: Add method to reload configfile from disk
Maranba72e62b41cb
diff --git a/fs/config/config.go b/fs/config/config.goindex be9d3b5cb..df18f66a5 100644--- a/fs/config/config.go+++ b/fs/config/config.go@@ -1340,6 +1340,16 @@ func FileDeleteKey(section, key string) bool {var matchEnv = regexp.MustCompile(`^RCLONE_CONFIG_(.*?)_TYPE=.*$`)+// FileRefresh ensures the latest configFile is loaded from disk+func FileRefresh() error {+ reloadedConfigFile, err := loadConfigFile()+ if err != nil {+ return err+ }+ configFile = reloadedConfigFile+ return nil+}+// FileSections returns the sections in the config file// including any defined by environment variables.func FileSections() []string {diff --git a/fs/config/config_test.go b/fs/config/config_test.goindex efd654bba..cde4da35c 100644--- a/fs/config/config_test.go+++ b/fs/config/config_test.go@@ -1,6 +1,7 @@package configimport (+ "bytes""fmt""io/ioutil""os"@@ -292,3 +293,21 @@ func TestMatchProvider(t *testing.T) {assert.Equal(t, test.want, got, what)}}++func TestFileRefresh(t *testing.T) {+ defer testConfigFile(t, "refresh.conf")()+ require.NoError(t, CreateRemote("refresh_test", "config_test_remote", rc.Params{+ "bool": true,+ }))+ b, err := ioutil.ReadFile(ConfigPath)+ assert.NoError(t, err)++ b = bytes.Replace(b, []byte("refresh_test"), []byte("refreshed_test"), 1)+ err = ioutil.WriteFile(ConfigPath, b, 0644)+ assert.NoError(t, err)++ assert.NotEqual(t, []string{"refreshed_test"}, configFile.GetSectionList())+ err = FileRefresh()+ assert.NoError(t, err)+ assert.Equal(t, []string{"refreshed_test"}, configFile.GetSectionList())+}