diff --git a/cmd_install.go b/cmd_install.go index 286dfad..c2c4a8d 100644 --- a/cmd_install.go +++ b/cmd_install.go @@ -2,6 +2,7 @@ package main import ( "context" + "errors" "fmt" "os" "path/filepath" @@ -149,7 +150,7 @@ the latest version for the current OS will be used.`, err = downloader.Download(cmd.Context(), installPath, nil, nil) // Check if download was cancelled (Ctrl+C) - if err == context.Canceled { + if errors.Is(err, context.Canceled) { return nil // Exit cleanly without error } diff --git a/cmd_update.go b/cmd_update.go index 404daf8..98ad8f6 100644 --- a/cmd_update.go +++ b/cmd_update.go @@ -2,6 +2,7 @@ package main import ( "context" + "errors" "fmt" "github.com/gustash/freecarnival/auth" @@ -104,7 +105,7 @@ func newUpdateCmd() *cobra.Command { err = updater.Update(cmd.Context()) // Check if update was cancelled (Ctrl+C) - if err == context.Canceled { + if errors.Is(err, context.Canceled) { return nil // Exit cleanly without error } diff --git a/download/downloader.go b/download/downloader.go index 77fb2c3..84baecc 100644 --- a/download/downloader.go +++ b/download/downloader.go @@ -3,6 +3,7 @@ package download import ( "context" + "errors" "fmt" "net/http" "os" @@ -153,7 +154,7 @@ func (d *Downloader) Download(ctx context.Context, installPath string, buildMani err = d.downloadAndWrite(ctx, fileChunks, fileInfoMap, resumeState) - if ctx.Err() == context.Canceled { + if errors.Is(ctx.Err(), context.Canceled) { d.progress.Abort() logger.Info("\n\nDownload paused. Progress has been saved.") logger.Info("Run the same install command again to resume from where you left off.") @@ -457,7 +458,7 @@ func (d *Downloader) downloadWorker(ctx context.Context, downloader *ChunkDownlo data, err := downloader.Download(ctx, job.FileIndex, job.ChunkSHA) - if err == context.Canceled { + if errors.Is(err, context.Canceled) { d.memory.Release(manifest.MaxChunkSize) return }