diff --git a/internal/functions/panupload/upload_task_unit.go b/internal/functions/panupload/upload_task_unit.go index bcc67e4..1910f61 100644 --- a/internal/functions/panupload/upload_task_unit.go +++ b/internal/functions/panupload/upload_task_unit.go @@ -518,16 +518,20 @@ StepUploadPrepareUpload: ContentHashName: contentHashName, ProofCode: proofCode, ProofVersion: "v1", + LocalCreatedAt: utils.UnixTime2LocalFormatStr(utu.LocalFileChecksum.ModTime), + LocalModifiedAt: utils.UnixTime2LocalFormatStr(utu.LocalFileChecksum.ModTime), } } else { // 不支持秒传,不计算SHA1,直接上传文件 appCreateUploadFileParam = &aliyunpan.CreateFileUploadParam{ - DriveId: utu.DriveId, - Name: filepath.Base(utu.SavePath), - Size: utu.LocalFileChecksum.Length, - CheckNameMode: checkNameMode, - ParentFileId: rs.FileId, - BlockSize: utu.BlockSize, + DriveId: utu.DriveId, + Name: filepath.Base(utu.SavePath), + Size: utu.LocalFileChecksum.Length, + CheckNameMode: checkNameMode, + ParentFileId: rs.FileId, + BlockSize: utu.BlockSize, + LocalCreatedAt: utils.UnixTime2LocalFormatStr(utu.LocalFileChecksum.ModTime), + LocalModifiedAt: utils.UnixTime2LocalFormatStr(utu.LocalFileChecksum.ModTime), } } diff --git a/internal/functions/panupload/utils.go b/internal/functions/panupload/utils.go index 6c72dee..aff984f 100644 --- a/internal/functions/panupload/utils.go +++ b/internal/functions/panupload/utils.go @@ -94,10 +94,3 @@ func CalcFilePreHash(filePath string) string { hashCode := hex.EncodeToString(shaBytes) return strings.ToUpper(hashCode) } - -// UnixTime2LocalFormatStr 时间戳转换为东8区时间字符串 -func UnixTime2LocalFormatStr(unixTime int64) string { - t := time.Unix(unixTime, 0) - cz := time.FixedZone("CST", 8*3600) // 东8区 - return t.In(cz).Format("2006-01-02T15:04:05.000Z") -} diff --git a/internal/syncdrive/file_action_task.go b/internal/syncdrive/file_action_task.go index f139983..b0937ba 100644 --- a/internal/syncdrive/file_action_task.go +++ b/internal/syncdrive/file_action_task.go @@ -506,6 +506,8 @@ func (f *FileActionTask) uploadFile(ctx context.Context) error { BlockSize: f.syncItem.UploadBlockSize, ProofCode: proofCode, ProofVersion: "v1", + LocalCreatedAt: utils.UnixTime2LocalFormatStr(localFile.ModTime), + LocalModifiedAt: utils.UnixTime2LocalFormatStr(localFile.ModTime), } if uploadOpEntity, err := f.panClient.OpenapiPanClient().CreateUploadFile(appCreateUploadFileParam); err != nil { logger.Verbosef("创建云盘上传任务失败: %s\n", targetPanFilePath) diff --git a/internal/utils/utils.go b/internal/utils/utils.go index e2f0ba3..bc61eee 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -281,3 +281,10 @@ func ResizeUploadBlockSize(fileSize, defaultBlockSize int64) int64 { sizeOfMB := int64(math.Ceil(float64(fileSize) / float64(aliyunpan.MaxPartNum) / 1024.0)) return sizeOfMB * 1024 } + +// UnixTime2LocalFormatStr 时间戳转换为东8区时间字符串 +func UnixTime2LocalFormatStr(unixTime int64) string { + t := time.Unix(unixTime, 0) + cz := time.FixedZone("CST", 8*3600) // 东8区 + return t.In(cz).Format("2006-01-02T15:04:05.000Z") +}