// UpdateMany updates everything from the given list of names that the // store says is updateable. If the list is empty, update everything. // Note that the state must be locked by the caller. func UpdateMany(st *state.State, names []string, userID int) ([]string, []*state.TaskSet, error) { user, err := userFromUserID(st, userID) if err != nil { return nil, nil, err } updates, stateByID, err := refreshCandidates(st, names, user) if err != nil { return nil, nil, err } if ValidateRefreshes != nil && len(updates) != 0 { updates, err = ValidateRefreshes(st, updates, userID) if err != nil { // not doing "refresh all" report the error if len(names) != 0 { return nil, nil, err } // doing "refresh all", log the problems logger.Noticef("cannot refresh some snaps: %v", err) } } updated := make([]string, 0, len(updates)) tasksets := make([]*state.TaskSet, 0, len(updates)) for _, update := range updates { snapst := stateByID[update.SnapID] ss := &SnapSetup{ Channel: snapst.Channel, UserID: userID, Flags: snapst.Flags.ForSnapSetup(), DownloadInfo: &update.DownloadInfo, SideInfo: &update.SideInfo, } ts, err := doInstall(st, snapst, ss) if err != nil { if len(names) == 0 { // doing "refresh all", just skip this snap logger.Noticef("cannot refresh snap %q: %v", update.Name(), err) continue } return nil, nil, err } ts.JoinLane(st.NewLane()) updated = append(updated, update.Name()) tasksets = append(tasksets, ts) } return updated, tasksets, nil }