Add multi-disk copy workflow

This commit is contained in:
2026-04-23 22:24:32 +03:00
parent 5b3cb9e393
commit 31bac2b5d8
10 changed files with 468 additions and 204 deletions

View File

@@ -19,6 +19,7 @@ const (
type Task struct {
ID string `json:"id"`
DiskID string `json:"disk_id"`
Type string `json:"type"`
Status Status `json:"status"`
Progress int `json:"progress"`
@@ -43,9 +44,10 @@ func NewStore() *Store {
return &Store{tasks: make(map[string]*Task)}
}
func (s *Store) Create(taskType string) *Task {
func (s *Store) Create(taskType, diskID string) *Task {
t := &Task{
ID: uuid.New().String(),
DiskID: diskID,
Type: taskType,
Status: StatusQueued,
CreatedAt: time.Now().UTC(),
@@ -77,11 +79,11 @@ func (s *Store) Update(id string, fn func(*Task)) {
}
}
func (s *Store) ActiveTask() (*Task, bool) {
func (s *Store) ActiveTaskByDisk(diskID string) (*Task, bool) {
s.mu.RLock()
defer s.mu.RUnlock()
for _, t := range s.tasks {
if t.Status == StatusQueued || t.Status == StatusRunning {
if t.DiskID == diskID && (t.Status == StatusQueued || t.Status == StatusRunning) {
copy := *t
return &copy, true
}