mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-11 16:06:02 +08:00
fix: fix the issue of import cycle (#7757)
This commit is contained in:
parent
fcc3f8e216
commit
680e237ef3
4 changed files with 2 additions and 22 deletions
|
@ -821,7 +821,7 @@ func getAppFromRepo(downloadPath string) error {
|
|||
global.LOG.Infof("[AppStore] download file from %s", downloadUrl)
|
||||
fileOp := files.NewFileOp()
|
||||
packagePath := filepath.Join(constant.ResourceDir, filepath.Base(downloadUrl))
|
||||
if err := fileOp.DownloadFileWithProxy(downloadUrl, packagePath); err != nil {
|
||||
if err := fileOp.DownloadFile(downloadUrl, packagePath); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := fileOp.Decompress(packagePath, constant.ResourceDir, files.SdkZip, ""); err != nil {
|
||||
|
|
|
@ -897,7 +897,7 @@ func downloadApp(app model.App, appDetail model.AppDetail, appInstall *model.App
|
|||
}
|
||||
}()
|
||||
|
||||
if err = fileOp.DownloadFileWithProxy(appDetail.DownloadUrl, filePath); err != nil {
|
||||
if err = fileOp.DownloadFile(appDetail.DownloadUrl, filePath); err != nil {
|
||||
if logger == nil {
|
||||
global.LOG.Errorf("download app[%s] error %v", app.Name, err)
|
||||
} else {
|
||||
|
|
|
@ -3,7 +3,6 @@ package files
|
|||
import (
|
||||
"archive/zip"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
|
@ -333,25 +332,6 @@ func (f FileOp) DownloadFile(url, dst string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (f FileOp) DownloadFileWithProxy(url, dst string) error {
|
||||
_, resp, err := req_helper.HandleRequest(url, http.MethodGet, constant.TimeOut5m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create download file [%s] error, err %s", dst, err.Error())
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
reader := bytes.NewReader(resp)
|
||||
if _, err = io.Copy(out, reader); err != nil {
|
||||
return fmt.Errorf("save download file [%s] error, err %s", dst, err.Error())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f FileOp) Cut(oldPaths []string, dst, name string, cover bool) error {
|
||||
for _, p := range oldPaths {
|
||||
var dstPath string
|
||||
|
|
Loading…
Add table
Reference in a new issue