func checkChangeConflict(s *state.State, snapName string) error { for _, task := range s.Tasks() { k := task.Kind() chg := task.Change() if (k == "link-snap" || k == "unlink-snap") && (chg == nil || !chg.Status().Ready()) { ss, err := TaskSnapSetup(task) if err != nil { return fmt.Errorf("internal error: cannot obtain snap setup from task: %s", task.Summary()) } if ss.Name == snapName { return fmt.Errorf("snap %q has changes in progress", snapName) } } } return nil }
func verifyInstallUpdateTasks(c *C, curActive bool, ts *state.TaskSet, st *state.State) { i := 0 n := 5 if curActive { n++ } c.Assert(ts.Tasks(), HasLen, n) // all tasks are accounted c.Assert(st.Tasks(), HasLen, n) c.Assert(ts.Tasks()[i].Kind(), Equals, "download-snap") i++ c.Assert(ts.Tasks()[i].Kind(), Equals, "mount-snap") i++ if curActive { c.Assert(ts.Tasks()[i].Kind(), Equals, "unlink-current-snap") i++ } c.Assert(ts.Tasks()[i].Kind(), Equals, "copy-snap-data") i++ c.Assert(ts.Tasks()[i].Kind(), Equals, "setup-profiles") i++ c.Assert(ts.Tasks()[i].Kind(), Equals, "link-snap") }