mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 14:32:14 +08:00
add upload file record #206
This commit is contained in:
parent
6abab46db0
commit
ea9279e45e
@ -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 {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user