forked from TrueCloudLab/rclone
plugins: Create availablePlugins config file if it does not exist.
This commit is contained in:
parent
09b79679cd
commit
dffcc99373
1 changed files with 18 additions and 7 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -97,15 +98,25 @@ func (p *Plugins) readFromFile() (err error) {
|
|||
return err
|
||||
}
|
||||
availablePluginsJSON := filepath.Join(pluginsConfigPath, p.fileName)
|
||||
_, err = os.Stat(availablePluginsJSON)
|
||||
if err == nil {
|
||||
data, err := ioutil.ReadFile(availablePluginsJSON)
|
||||
if err != nil {
|
||||
// create a file ?
|
||||
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
|
||||
}
|
||||
|
||||
func (p *Plugins) addPlugin(pluginName string, packageJSONPath string) (err error) {
|
||||
|
|
Loading…
Reference in a new issue