- Updated command usage in English and Simplified Chinese localization files to reflect changes in transfer command syntax. - Removed batch import task implementation, replacing it with a new transfer task implementation. - Introduced new task structure and progress tracking for file transfers. - Updated task type enumeration to replace batch import with transfer. - Added new fields in data structures to support transfer operations. - Implemented file handling and progress reporting for the transfer task.
74 lines
1.3 KiB
Go
74 lines
1.3 KiB
Go
package transfer
|
|
|
|
type TaskElementInfo interface {
|
|
FileName() string
|
|
FileSize() int64
|
|
GetSourcePath() string
|
|
SourceStorageName() string
|
|
}
|
|
|
|
func (e *TaskElement) FileName() string {
|
|
return e.FileInfo.Name
|
|
}
|
|
|
|
func (e *TaskElement) FileSize() int64 {
|
|
return e.FileInfo.Size
|
|
}
|
|
|
|
func (e *TaskElement) GetSourcePath() string {
|
|
return e.SourcePath
|
|
}
|
|
|
|
func (e *TaskElement) SourceStorageName() string {
|
|
return e.SourceStorage.Name()
|
|
}
|
|
|
|
type TaskInfo interface {
|
|
TaskID() string
|
|
TotalSize() int64
|
|
Uploaded() int64
|
|
Count() int
|
|
Processing() []TaskElementInfo
|
|
FailedFiles() []string
|
|
}
|
|
|
|
func (t *Task) TotalSize() int64 {
|
|
return t.totalSize
|
|
}
|
|
|
|
func (t *Task) Uploaded() int64 {
|
|
return t.uploaded.Load()
|
|
}
|
|
|
|
func (t *Task) Count() int {
|
|
return len(t.elems)
|
|
}
|
|
|
|
func (t *Task) Processing() []TaskElementInfo {
|
|
t.processingMu.RLock()
|
|
defer t.processingMu.RUnlock()
|
|
|
|
result := make([]TaskElementInfo, 0, len(t.processing))
|
|
for _, elem := range t.processing {
|
|
result = append(result, elem)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (t *Task) FailedFiles() []string {
|
|
t.processingMu.RLock()
|
|
defer t.processingMu.RUnlock()
|
|
|
|
result := make([]string, 0, len(t.failed))
|
|
for id := range t.failed {
|
|
// Find the element by ID
|
|
for _, elem := range t.elems {
|
|
if elem.ID == id {
|
|
result = append(result, elem.FileInfo.Name)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
return result
|
|
}
|