This is an automated email from the ASF dual-hosted git repository. kumfo pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git
commit 188444f56e9ee8fe9ea18443d0663f9ff8bac563 Author: kumfo <[email protected]> AuthorDate: Fri Jul 19 15:54:18 2024 +0800 fix(cdn): aliyun oss cdn add sync status check --- cdn-aliyunoss/aliyunoss.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/cdn-aliyunoss/aliyunoss.go b/cdn-aliyunoss/aliyunoss.go index 9001674..a145341 100644 --- a/cdn-aliyunoss/aliyunoss.go +++ b/cdn-aliyunoss/aliyunoss.go @@ -29,6 +29,7 @@ import ( "github.com/apache/incubator-answer/ui" "github.com/segmentfault/pacman/log" "io" + "io/fs" "os" "path/filepath" "strconv" @@ -148,13 +149,14 @@ func (c *CDN) scanStaticPathFiles(fileName string) (err error) { continue } + var file fs.File filePath := filepath.Join(fileName, info.Name()) fi, _ := info.Info() size := fi.Size() - file, err := os.Open(filePath) + file, err = os.Open(filePath) if err != nil { log.Error("open file failed: %v", err) - return err + return } suffix := staticPath[:1] @@ -170,7 +172,7 @@ func (c *CDN) scanStaticPathFiles(fileName string) (err error) { "\"/static": "", }), size) if err != nil { - return err + return } continue } @@ -183,7 +185,7 @@ func (c *CDN) scanStaticPathFiles(fileName string) (err error) { }), size) if err != nil { - return err + return } continue } @@ -194,7 +196,7 @@ func (c *CDN) scanStaticPathFiles(fileName string) (err error) { }), size) if err != nil { - return err + return } continue } @@ -202,7 +204,7 @@ func (c *CDN) scanStaticPathFiles(fileName string) (err error) { err = c.Upload(filePath, file, size) if err != nil { - return err + return } } return nil @@ -223,14 +225,15 @@ func (c *CDN) scanEmbedFiles(fileName string) (err error) { continue } + var file fs.File filePath := filepath.Join(fileName, info.Name()) fi, _ := info.Info() size := fi.Size() - file, err := ui.Build.Open(filePath) + file, err = ui.Build.Open(filePath) defer file.Close() if err != nil { log.Error("open file failed: %v", err) - return err + return } filePath = strings.TrimPrefix(filePath, "build/") @@ -242,7 +245,7 @@ func (c *CDN) scanEmbedFiles(fileName string) (err error) { "\"/static": "", }), size) if err != nil { - return err + return } continue } @@ -254,7 +257,7 @@ func (c *CDN) scanEmbedFiles(fileName string) (err error) { "=\"/\",": "=\"\",", }), size) if err != nil { - return err + return } continue } @@ -264,7 +267,7 @@ func (c *CDN) scanEmbedFiles(fileName string) (err error) { "url(/static": "url(../../static", }), size) if err != nil { - return err + return } continue }
