Skip to content

Commit 68124d5

Browse files
authored
Merge pull request #376 from merico-dev/fix-init-download
fix: fix the return error
2 parents 2d4547b + e3e5b8b commit 68124d5

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

internal/pkg/pluginmanager/manager.go

+14-15
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,25 @@ func DownloadPlugins(conf *configloader.Config) error {
3333
pluginMD5FileName := configloader.GetPluginMD5FileName(&tool)
3434
// plugin does not exist
3535
if _, err := os.Stat(filepath.Join(pluginDir, pluginFileName)); err != nil {
36-
if errors.Is(err, os.ErrNotExist) {
37-
// download .so file
38-
if err := dc.download(pluginDir, pluginFileName, version.Version); err != nil {
39-
return err
40-
}
41-
log.Successf("[%s] download succeeded.", pluginFileName)
36+
if !errors.Is(err, os.ErrNotExist) {
37+
return err
4238
}
43-
return err
39+
// download .so file
40+
if err := dc.download(pluginDir, pluginFileName, version.Version); err != nil {
41+
return err
42+
}
43+
log.Successf("[%s] download succeeded.", pluginFileName)
4444
}
4545
// .md5 does not exist
4646
if _, err := os.Stat(filepath.Join(pluginDir, pluginMD5FileName)); err != nil {
47-
if errors.Is(err, os.ErrNotExist) {
48-
// download .md5 file
49-
if err := dc.download(pluginDir, pluginMD5FileName, version.Version); err != nil {
50-
return err
51-
}
52-
log.Successf("[%s] download succeeded.", pluginMD5FileName)
47+
if !errors.Is(err, os.ErrNotExist) {
48+
return err
5349
}
54-
return err
50+
// download .md5 file
51+
if err := dc.download(pluginDir, pluginMD5FileName, version.Version); err != nil {
52+
return err
53+
}
54+
log.Successf("[%s] download succeeded.", pluginMD5FileName)
5555
}
5656
// check if the plugin matches with .md5
5757
isMD5Match, err := md5.FileMatchesMD5(filepath.Join(pluginDir, pluginFileName), filepath.Join(pluginDir, pluginMD5FileName))
@@ -101,7 +101,6 @@ func CheckLocalPlugins(conf *configloader.Config) error {
101101
}
102102
return err
103103
}
104-
105104
if err := pluginAndMD5Matches(pluginDir, pluginFileName, pluginMD5FileName, tool.Name); err != nil {
106105
return err
107106
}

0 commit comments

Comments
 (0)