Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

plugins: Create availablePlugins config file if it does not exist.

Chaitanya Bankanhaldffcc99373a4
diff --git a/fs/rc/webgui/plugins.go b/fs/rc/webgui/plugins.go
index 645a02830..d6b2cf117 100644
--- a/fs/rc/webgui/plugins.go
+++ b/fs/rc/webgui/plugins.go
@@ -7,6 +7,7 @@ import (
"net/http"
"net/http/httputil"
"net/url"
+ "os"
"path/filepath"
"regexp"
"strings"
@@ -97,13 +98,23 @@ func (p *Plugins) readFromFile() (err error) {
return err
}
availablePluginsJSON := filepath.Join(pluginsConfigPath, p.fileName)
- data, err := ioutil.ReadFile(availablePluginsJSON)
- if err != nil {
- // create a file ?
- }
- err = json.Unmarshal(data, &p)
- if err != nil {
- fs.Logf(nil, "%s", err)
+ _, err = os.Stat(availablePluginsJSON)
+ if err == nil {
+ data, err := ioutil.ReadFile(availablePluginsJSON)
+ if err != nil {
+ return err
+ }
+ err = json.Unmarshal(data, &p)
+ if err != nil {
+ fs.Logf(nil, "%s", err)
+ }
+ return nil
+ } else if os.IsNotExist(err) {
+ // path does not exist
+ err = p.writeToFile()
+ if err != nil {
+ return err
+ }
}
return nil
}