mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 22:42:15 +08:00
add upload file record #206
This commit is contained in:
parent
6abab46db0
commit
ea9279e45e
@ -17,6 +17,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/tickstep/aliyunpan-api/aliyunpan/apierror"
|
"github.com/tickstep/aliyunpan-api/aliyunpan/apierror"
|
||||||
"github.com/tickstep/aliyunpan/cmder"
|
"github.com/tickstep/aliyunpan/cmder"
|
||||||
|
"github.com/tickstep/aliyunpan/internal/log"
|
||||||
"github.com/tickstep/aliyunpan/internal/plugins"
|
"github.com/tickstep/aliyunpan/internal/plugins"
|
||||||
"github.com/tickstep/aliyunpan/internal/utils"
|
"github.com/tickstep/aliyunpan/internal/utils"
|
||||||
"github.com/tickstep/library-go/requester/rio/speeds"
|
"github.com/tickstep/library-go/requester/rio/speeds"
|
||||||
@ -333,6 +334,9 @@ func RunUpload(localPaths []string, savePath string, opt *UploadOptions) {
|
|||||||
// 获取当前插件
|
// 获取当前插件
|
||||||
plugin, _ := pluginManger.GetPlugin()
|
plugin, _ := pluginManger.GetPlugin()
|
||||||
|
|
||||||
|
// 上传记录器
|
||||||
|
fileRecorder := log.NewFileRecorder(config.GetLogDir() + "/upload_file_records.csv")
|
||||||
|
|
||||||
// 遍历指定的文件并创建上传任务
|
// 遍历指定的文件并创建上传任务
|
||||||
for _, curPath := range localPaths {
|
for _, curPath := range localPaths {
|
||||||
var walkFunc localfile.MyWalkFunc
|
var walkFunc localfile.MyWalkFunc
|
||||||
@ -420,6 +424,7 @@ func RunUpload(localPaths []string, savePath string, opt *UploadOptions) {
|
|||||||
IsOverwrite: opt.IsOverwrite,
|
IsOverwrite: opt.IsOverwrite,
|
||||||
UseInternalUrl: opt.UseInternalUrl,
|
UseInternalUrl: opt.UseInternalUrl,
|
||||||
GlobalSpeedsStat: globalSpeedsStat,
|
GlobalSpeedsStat: globalSpeedsStat,
|
||||||
|
FileRecorder: fileRecorder,
|
||||||
}, opt.MaxRetry)
|
}, opt.MaxRetry)
|
||||||
fmt.Printf("[%s] 加入上传队列: %s\n", taskinfo.Id(), file.LogicPath)
|
fmt.Printf("[%s] 加入上传队列: %s\n", taskinfo.Id(), file.LogicPath)
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,6 +15,7 @@ package panupload
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/tickstep/aliyunpan/internal/log"
|
||||||
"github.com/tickstep/aliyunpan/internal/plugins"
|
"github.com/tickstep/aliyunpan/internal/plugins"
|
||||||
"github.com/tickstep/library-go/logger"
|
"github.com/tickstep/library-go/logger"
|
||||||
"os"
|
"os"
|
||||||
@ -71,6 +72,9 @@ type (
|
|||||||
|
|
||||||
// 全局速度统计
|
// 全局速度统计
|
||||||
GlobalSpeedsStat *speeds.Speeds
|
GlobalSpeedsStat *speeds.Speeds
|
||||||
|
|
||||||
|
// 上传文件记录器
|
||||||
|
FileRecorder *log.FileRecorder
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -239,6 +243,16 @@ func (utu *UploadTaskUnit) OnRetry(lastRunResult *taskframework.TaskUnitRunResul
|
|||||||
func (utu *UploadTaskUnit) OnSuccess(lastRunResult *taskframework.TaskUnitRunResult) {
|
func (utu *UploadTaskUnit) OnSuccess(lastRunResult *taskframework.TaskUnitRunResult) {
|
||||||
// 执行插件
|
// 执行插件
|
||||||
utu.pluginCallback("success")
|
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) {
|
func (utu *UploadTaskUnit) OnFailed(lastRunResult *taskframework.TaskUnitRunResult) {
|
||||||
|
Loading…
Reference in New Issue
Block a user