mirror of
https://github.com/rclone/rclone.git
synced 2025-01-19 04:47:54 +02:00
plugins: Create availablePlugins config file if it does not exist.
This commit is contained in:
parent
09b79679cd
commit
dffcc99373
@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@ -97,15 +98,25 @@ func (p *Plugins) readFromFile() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
availablePluginsJSON := filepath.Join(pluginsConfigPath, p.fileName)
|
availablePluginsJSON := filepath.Join(pluginsConfigPath, p.fileName)
|
||||||
|
_, err = os.Stat(availablePluginsJSON)
|
||||||
|
if err == nil {
|
||||||
data, err := ioutil.ReadFile(availablePluginsJSON)
|
data, err := ioutil.ReadFile(availablePluginsJSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// create a file ?
|
return err
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(data, &p)
|
err = json.Unmarshal(data, &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Logf(nil, "%s", err)
|
fs.Logf(nil, "%s", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
} else if os.IsNotExist(err) {
|
||||||
|
// path does not exist
|
||||||
|
err = p.writeToFile()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plugins) addPlugin(pluginName string, packageJSONPath string) (err error) {
|
func (p *Plugins) addPlugin(pluginName string, packageJSONPath string) (err error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user