diff --git a/internal/command/upload.go b/internal/command/upload.go index 7fbd723..c6efff0 100644 --- a/internal/command/upload.go +++ b/internal/command/upload.go @@ -17,6 +17,7 @@ import ( "fmt" "github.com/tickstep/aliyunpan-api/aliyunpan/apierror" "github.com/tickstep/aliyunpan/cmder" + "github.com/tickstep/aliyunpan/internal/log" "github.com/tickstep/aliyunpan/internal/plugins" "github.com/tickstep/aliyunpan/internal/utils" "github.com/tickstep/library-go/requester/rio/speeds" @@ -333,6 +334,9 @@ func RunUpload(localPaths []string, savePath string, opt *UploadOptions) { // 获取当前插件 plugin, _ := pluginManger.GetPlugin() + // 上传记录器 + fileRecorder := log.NewFileRecorder(config.GetLogDir() + "/upload_file_records.csv") + // 遍历指定的文件并创建上传任务 for _, curPath := range localPaths { var walkFunc localfile.MyWalkFunc @@ -420,6 +424,7 @@ func RunUpload(localPaths []string, savePath string, opt *UploadOptions) { IsOverwrite: opt.IsOverwrite, UseInternalUrl: opt.UseInternalUrl, GlobalSpeedsStat: globalSpeedsStat, + FileRecorder: fileRecorder, }, opt.MaxRetry) fmt.Printf("[%s] 加入上传队列: %s\n", taskinfo.Id(), file.LogicPath) } else { diff --git a/internal/functions/panupload/upload_task_unit.go b/internal/functions/panupload/upload_task_unit.go index e8c5e70..ecc8830 100644 --- a/internal/functions/panupload/upload_task_unit.go +++ b/internal/functions/panupload/upload_task_unit.go @@ -15,6 +15,7 @@ package panupload import ( "fmt" + "github.com/tickstep/aliyunpan/internal/log" "github.com/tickstep/aliyunpan/internal/plugins" "github.com/tickstep/library-go/logger" "os" @@ -71,6 +72,9 @@ type ( // 全局速度统计 GlobalSpeedsStat *speeds.Speeds + + // 上传文件记录器 + FileRecorder *log.FileRecorder } ) @@ -239,6 +243,16 @@ func (utu *UploadTaskUnit) OnRetry(lastRunResult *taskframework.TaskUnitRunResul func (utu *UploadTaskUnit) OnSuccess(lastRunResult *taskframework.TaskUnitRunResult) { // 执行插件 utu.pluginCallback("success") + + // 上传文件数据记录 + if config.Config.FileRecordConfig == "1" { + utu.FileRecorder.Append(&log.FileRecordItem{ + Status: "成功", + TimeStr: utils.NowTimeStr(), + FileSize: utu.LocalFileChecksum.LocalFileMeta.Length, + FilePath: utu.LocalFileChecksum.Path.LogicPath, + }) + } } func (utu *UploadTaskUnit) OnFailed(lastRunResult *taskframework.TaskUnitRunResult) {