Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 6238053

Browse files
committed
internal/cmd/update.go: handle copy error from archive
1 parent 3ba1bed commit 6238053

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

internal/cmd/update.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (u *updater) Run(ctx context.Context, force bool, coderURLArg string, versi
145145
if !force {
146146
label := fmt.Sprintf("Do you want to download version %s instead", desiredVersion)
147147
if _, err := u.confirmF(label); err != nil {
148-
return clog.Fatal("failed to confirm update", clog.Tipf(`use "--force" to update without confirmation`))
148+
return clog.Fatal("user cancelled operation", clog.Tipf(`use "--force" to update without confirmation`))
149149
}
150150
}
151151

@@ -383,7 +383,10 @@ func extractFromTgz(path string, archive []byte) ([]byte, error) {
383383
}
384384
fi := hdr.FileInfo()
385385
if fi.Name() == path && fi.Mode().IsRegular() {
386-
_, _ = io.Copy(bw, tr)
386+
_, err = io.Copy(bw, tr)
387+
if err != nil {
388+
return nil, xerrors.Errorf("failed to read file %q from archive", fi.Name())
389+
}
387390
break
388391
}
389392
}

internal/cmd/update_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func Test_updater_run(t *testing.T) {
197197
u := fromParams(p)
198198
assertFileContent(t, p.Fakefs, fakeExePathLinux, fakeOldVersion)
199199
err := u.Run(p.Ctx, false, fakeCoderURL, "")
200-
assertCLIError(t, "update coder - user cancelled", err, "failed to confirm update", "")
200+
assertCLIError(t, "update coder - user cancelled", err, "user cancelled operation", "")
201201
assertFileContent(t, p.Fakefs, fakeExePathLinux, fakeOldVersion)
202202
})
203203

0 commit comments

Comments
 (0)