From 89f618d53335b773dd2c60788d63e14ae38b315f Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 11 Nov 2021 09:55:55 +0800 Subject: [PATCH 1/3] fix time error --- modules/storage/obs.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/storage/obs.go b/modules/storage/obs.go index 8e72c03c4..a7ea8a91f 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -5,13 +5,12 @@ package storage import ( + "github.com/unknwon/com" "io" "path" "strconv" "strings" - "github.com/unknwon/com" - "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/obs" "code.gitea.io/gitea/modules/setting" @@ -213,7 +212,7 @@ func GetObsListObject(jobName, parentDir string) ([]FileInfo, error) { } fileInfo := FileInfo{ - ModTime: val.LastModified.Format("2006-01-02 15:04:05"), + ModTime: val.LastModified.Local().Format("2006-01-02 15:04:05"), FileName: fileName, Size: val.Size, IsDir:isDir, From c932eb3d4fc8e930b102426d0e05e4d420261523 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 11 Nov 2021 09:56:48 +0800 Subject: [PATCH 2/3] fix time error --- modules/storage/obs.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/storage/obs.go b/modules/storage/obs.go index a7ea8a91f..7c8f780ef 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -5,7 +5,6 @@ package storage import ( - "github.com/unknwon/com" "io" "path" "strconv" @@ -14,6 +13,8 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/obs" "code.gitea.io/gitea/modules/setting" + + "github.com/unknwon/com" ) type FileInfo struct { From e3a53f5a5dcc57ad12c8aef99887d882851b7bf0 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 11 Nov 2021 09:58:21 +0800 Subject: [PATCH 3/3] fix time error --- modules/storage/obs.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/storage/obs.go b/modules/storage/obs.go index 7c8f780ef..239580adb 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -185,10 +185,10 @@ func GetObsListObject(jobName, parentDir string) ([]FileInfo, error) { for _, val := range output.Contents { str1 := strings.Split(val.Key, "/") var isDir bool - var fileName,nextParentDir string + var fileName, nextParentDir string if strings.HasSuffix(val.Key, "/") { //dirs in next level dir - if len(str1) - len(strPrefix) > 2 { + if len(str1)-len(strPrefix) > 2 { continue } fileName = str1[len(str1)-2] @@ -199,12 +199,12 @@ func GetObsListObject(jobName, parentDir string) ([]FileInfo, error) { nextParentDir = parentDir + "/" + fileName } - if fileName == strPrefix[len(strPrefix)-1] || (fileName + "/") == setting.OutPutPath { + if fileName == strPrefix[len(strPrefix)-1] || (fileName+"/") == setting.OutPutPath { continue } } else { //files in next level dir - if len(str1) - len(strPrefix) > 1 { + if len(str1)-len(strPrefix) > 1 { continue } fileName = str1[len(str1)-1] @@ -213,10 +213,10 @@ func GetObsListObject(jobName, parentDir string) ([]FileInfo, error) { } fileInfo := FileInfo{ - ModTime: val.LastModified.Local().Format("2006-01-02 15:04:05"), + ModTime: val.LastModified.Local().Format("2006-01-02 15:04:05"), FileName: fileName, - Size: val.Size, - IsDir:isDir, + Size: val.Size, + IsDir: isDir, ParenDir: nextParentDir, } fileInfos = append(fileInfos, fileInfo) @@ -257,7 +257,7 @@ func GetObsCreateSignedUrl(jobName, parentDir, fileName string) (string, error) input := &obs.CreateSignedUrlInput{} input.Bucket = setting.Bucket input.Key = strings.TrimPrefix(path.Join(setting.TrainJobModelPath, jobName, setting.OutPutPath, parentDir, fileName), "/") - + input.Expires = 60 * 60 input.Method = obs.HttpMethodGet