fix: fix the issue of import cycle (#7757)

This commit is contained in:
ssongliu 2025-01-22 15:52:45 +08:00 committed by GitHub
parent fcc3f8e216
commit 680e237ef3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 2 additions and 22 deletions

View file

@ -821,7 +821,7 @@ func getAppFromRepo(downloadPath string) error {
global.LOG.Infof("[AppStore] download file from %s", downloadUrl) global.LOG.Infof("[AppStore] download file from %s", downloadUrl)
fileOp := files.NewFileOp() fileOp := files.NewFileOp()
packagePath := filepath.Join(constant.ResourceDir, filepath.Base(downloadUrl)) 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 return err
} }
if err := fileOp.Decompress(packagePath, constant.ResourceDir, files.SdkZip, ""); err != nil { if err := fileOp.Decompress(packagePath, constant.ResourceDir, files.SdkZip, ""); err != nil {

View file

@ -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 { if logger == nil {
global.LOG.Errorf("download app[%s] error %v", app.Name, err) global.LOG.Errorf("download app[%s] error %v", app.Name, err)
} else { } else {

View file

@ -3,7 +3,6 @@ package files
import ( import (
"archive/zip" "archive/zip"
"bufio" "bufio"
"bytes"
"context" "context"
"crypto/tls" "crypto/tls"
"encoding/json" "encoding/json"
@ -333,25 +332,6 @@ func (f FileOp) DownloadFile(url, dst string) error {
return nil 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 { func (f FileOp) Cut(oldPaths []string, dst, name string, cover bool) error {
for _, p := range oldPaths { for _, p := range oldPaths {
var dstPath string var dstPath string