Skip to content

snap: abort install with ctrl+c#2401

Merged
mvo5 merged 14 commits into
canonical:masterfrom
stolowski:cancel-install
Dec 6, 2016
Merged

snap: abort install with ctrl+c#2401
mvo5 merged 14 commits into
canonical:masterfrom
stolowski:cancel-install

Conversation

@stolowski
Copy link
Copy Markdown
Contributor

@stolowski stolowski commented Dec 2, 2016

Abort snap install via ctrl+c. Includes update to the latest tomb package.

LP: #1592074

Copy link
Copy Markdown
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this change!

One trivial, and one detail we need to discuss.

Comment thread cmd/snap/cmd_snap_op.go Outdated
if err != nil {
fmt.Fprintf(Stderr, err.Error()+"\n")
}
os.Exit(1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't look right.. we need to ask for a stop rather than killing whatever is in progress midway through. Let's catch up online to discuss.

Comment thread image/helpers.go Outdated

pb := progress.NewTextProgress()
if err = sto.Download(name, targetFn, &snap.DownloadInfo, pb, opts.User); err != nil {
if err = sto.Download(nil, name, targetFn, &snap.DownloadInfo, pb, opts.User); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing nil, I suggest using context.TODO() everywhere we lack such a value, so that we know a context parameter is always supposed to exist. Otherwise we'll have to do if ctx != nil && everywhere, which is boring, and hopefully unnecessary since we'll gradually add it in the places we intend to support context.

Comment thread store/store.go Outdated
logger.Debugf("Retyring %s, attempt %d, delta time=%v ms", reqOptions.URL, attempt.Count(), delta)
}
resp, err = s.doRequest(client, reqOptions, user)
if ctx != nil && cancelled(ctx) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With logic suggested above, we can drop the != nil.

Copy link
Copy Markdown
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Copy link
Copy Markdown
Contributor

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one small question.

Comment thread cmd/snap/cmd_snap_op.go

func setupAbortHandler(changeId string) {
// Intercept sigint
c := make(chan os.Signal, 2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pardon my silly question, but why a capacity of 2 (and not e.g. 1 or 3)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason... it was just the value I saw in some example go code...

@mvo5 mvo5 merged commit 64dd19b into canonical:master Dec 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants