* refactor: a big refactor. wip * refactor: port handle file * refactor: place all handlers * fix: task info nil pointer * feat: enhance task progress tracking and context management * feat: cancel task * feat: stream mode * feat: silent mode * feat: dir cmd * refactor: remove unused old file * feat: rule cmd * feat: handle silent mode * feat: batch task * fix: batch task progress and temp file cleanup * refactor: update file creation and cleanup methods for better resource management * feat: add save command with silent mode handling * feat: message link * feat: update message prompts to include file count in storage selection * feat: slient save links * refactor: reduce dup code * feat: rule type * feat: chose dir * feat: refactor file handling and storage rules, improve error handling and logging * feat: rule mode * feat: telegraph pics * fix: tphpics nil pointer and inaccurate dirpath * feat: silent save telegraph * feat: add suffix to avoid file overwrite * feat: new storage telegram * chore: tidy go mod
57 lines
969 B
Go
57 lines
969 B
Go
package batchtftask
|
|
|
|
type TaskElementInfo interface {
|
|
FileName() string
|
|
FileSize() int64
|
|
StoragePath() string
|
|
StorageName() string
|
|
}
|
|
|
|
func (e *TaskElement) FileName() string {
|
|
return e.File.Name()
|
|
}
|
|
|
|
func (e *TaskElement) FileSize() int64 {
|
|
return e.File.Size()
|
|
}
|
|
|
|
func (e *TaskElement) StoragePath() string {
|
|
return e.Path
|
|
}
|
|
|
|
func (e *TaskElement) StorageName() string {
|
|
return e.Storage.Name()
|
|
}
|
|
|
|
type TaskInfo interface {
|
|
TaskID() string
|
|
TotalSize() int64
|
|
Downloaded() int64
|
|
Count() int
|
|
Processing() []TaskElementInfo
|
|
}
|
|
|
|
func (t *Task) TaskID() string {
|
|
return t.ID
|
|
}
|
|
|
|
func (t *Task) TotalSize() int64 {
|
|
return t.totalSize
|
|
}
|
|
|
|
func (t *Task) Downloaded() int64 {
|
|
return t.downloaded.Load()
|
|
}
|
|
|
|
func (t *Task) Count() int {
|
|
return len(t.Elems)
|
|
}
|
|
|
|
func (t *Task) Processing() []TaskElementInfo {
|
|
processing := make([]TaskElementInfo, 0, len(t.Elems))
|
|
for _, elem := range t.processing {
|
|
processing = append(processing, elem)
|
|
}
|
|
return processing
|
|
}
|