mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-19 14:53:44 +00:00
feat: new ui (#1455)
This commit is contained in:
742 files changed
+59951
-5934
No files matched your search
+366
-28
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+31
-2
@@ -36,6 +36,10 @@ type Task struct {
|
||||
timer *util.Timer
|
||||
statusLock *sync.Mutex
|
||||
lock *sync.Mutex
|
||||
statsLock *sync.Mutex
|
||||
statsLoaded bool
|
||||
stats *fetcher.Stats
|
||||
statsSnapshot json.RawMessage
|
||||
blobRefLock *sync.Mutex
|
||||
blobURL string
|
||||
runGeneration uint64
|
||||
@@ -43,6 +47,31 @@ type Task struct {
|
||||
uploadSpeedArr []int64
|
||||
}
|
||||
|
||||
// TaskRuntimeStatus is the lightweight, frequently refreshed view of a task.
|
||||
// It intentionally excludes request, resource and option metadata returned by
|
||||
// Task so detail pages can poll progress without repeatedly transferring the
|
||||
// full task object.
|
||||
type TaskRuntimeStatus struct {
|
||||
Status base.Status `json:"status"`
|
||||
Used int64 `json:"used"`
|
||||
Speed int64 `json:"speed"`
|
||||
Downloaded int64 `json:"downloaded"`
|
||||
Total int64 `json:"total"`
|
||||
UploadSpeed int64 `json:"uploadSpeed"`
|
||||
Uploaded int64 `json:"uploaded"`
|
||||
ExtractStatus ExtractStatus `json:"extractStatus"`
|
||||
ExtractProgress int `json:"extractProgress"`
|
||||
Files []FileRuntimeStatus `json:"files"`
|
||||
}
|
||||
|
||||
// FileRuntimeStatus maps one value returned by fetcher.Progress to its
|
||||
// original resource index. Fetchers return progress in SelectFiles order.
|
||||
type FileRuntimeStatus struct {
|
||||
Index int `json:"index"`
|
||||
Size int64 `json:"size"`
|
||||
Downloaded int64 `json:"downloaded"`
|
||||
}
|
||||
|
||||
func NewTask() *Task {
|
||||
id, err := gonanoid.New()
|
||||
if err != nil {
|
||||
@@ -88,10 +117,10 @@ func (t *Task) Name() string {
|
||||
func (t *Task) MarshalJSON() ([]byte, error) {
|
||||
type rawTaskType Task
|
||||
jsonTask := struct {
|
||||
rawTaskType
|
||||
*rawTaskType
|
||||
Name string `json:"name"`
|
||||
}{
|
||||
rawTaskType(*t),
|
||||
(*rawTaskType)(t),
|
||||
t.Name(),
|
||||
}
|
||||
return json.Marshal(jsonTask)
|
||||
|
||||
Reference in new issue
Block a user