Add multi-disk copy workflow
This commit is contained in:
@@ -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 ©, true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user