mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-24 22:34:04 +08:00
Merge 79e8b81758a814e7addaf4d291a48817a2ce8039 into 41bdab49aa8acca9e88862c3db55cd7a8a84ba6a
This commit is contained in:
commit
e052c73871
@ -24,6 +24,7 @@ func InitialTasks() []model.TaskItem {
|
||||
{Key: "copy", PersistData: "[]"},
|
||||
{Key: "download", PersistData: "[]"},
|
||||
{Key: "transfer", PersistData: "[]"},
|
||||
{Key: "upload", PersistData: "[]"},
|
||||
}
|
||||
return initialTaskItems
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ func taskFilterNegative(num int) int64 {
|
||||
}
|
||||
|
||||
func InitTaskManager() {
|
||||
fs.UploadTaskManager = tache.NewManager[*fs.UploadTask](tache.WithWorks(setting.GetInt(conf.TaskUploadThreadsNum, conf.Conf.Tasks.Upload.Workers)), tache.WithMaxRetry(conf.Conf.Tasks.Upload.MaxRetry)) //upload will not support persist
|
||||
fs.UploadTaskManager = tache.NewManager[*fs.UploadTask](tache.WithWorks(setting.GetInt(conf.TaskUploadThreadsNum, conf.Conf.Tasks.Upload.Workers)), tache.WithPersistFunction(db.GetTaskDataFunc("upload", conf.Conf.Tasks.Upload.TaskPersistant), db.UpdateTaskDataFunc("upload", conf.Conf.Tasks.Upload.TaskPersistant)), tache.WithMaxRetry(conf.Conf.Tasks.Upload.MaxRetry))
|
||||
op.RegisterSettingChangingCallback(func() {
|
||||
fs.UploadTaskManager.SetWorkersNumActive(taskFilterNegative(setting.GetInt(conf.TaskUploadThreadsNum, conf.Conf.Tasks.Upload.Workers)))
|
||||
})
|
||||
|
@ -16,12 +16,14 @@ import (
|
||||
type UploadTask struct {
|
||||
task.TaskExtension
|
||||
storage driver.Driver
|
||||
dstDirActualPath string
|
||||
FileName string `json:"file_name"`
|
||||
DstStorageMp string `json:"dst_storage_mp"`
|
||||
DstDirActualPath string `json:"dst_dir_actual_path"`
|
||||
file model.FileStreamer
|
||||
}
|
||||
|
||||
func (t *UploadTask) GetName() string {
|
||||
return fmt.Sprintf("upload %s to [%s](%s)", t.file.GetName(), t.storage.GetStorage().MountPath, t.dstDirActualPath)
|
||||
return fmt.Sprintf("upload %s to [%s](%s)", t.FileName, t.DstStorageMp, t.DstDirActualPath)
|
||||
}
|
||||
|
||||
func (t *UploadTask) GetStatus() string {
|
||||
@ -32,7 +34,7 @@ func (t *UploadTask) Run() error {
|
||||
t.ClearEndTime()
|
||||
t.SetStartTime(time.Now())
|
||||
defer func() { t.SetEndTime(time.Now()) }()
|
||||
return op.Put(t.Ctx(), t.storage, t.dstDirActualPath, t.file, t.SetProgress, true)
|
||||
return op.Put(t.Ctx(), t.storage, t.DstDirActualPath, t.file, t.SetProgress, true)
|
||||
}
|
||||
|
||||
var UploadTaskManager *tache.Manager[*UploadTask]
|
||||
@ -60,7 +62,9 @@ func putAsTask(ctx context.Context, dstDirPath string, file model.FileStreamer)
|
||||
Creator: taskCreator,
|
||||
},
|
||||
storage: storage,
|
||||
dstDirActualPath: dstDirActualPath,
|
||||
DstStorageMp: storage.GetStorage().MountPath,
|
||||
DstDirActualPath: dstDirActualPath,
|
||||
FileName: file.GetName(),
|
||||
file: file,
|
||||
}
|
||||
t.SetTotalBytes(file.GetSize())
|
||||
|
Loading…
x
Reference in New Issue
Block a user