From e6424dc8abad711f331c7a69873ffe40ffb0c562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Trinqu=C3=A9?= Date: Tue, 15 Feb 2022 20:02:45 +0100 Subject: [PATCH] Update icon.ico file mode (#1154) * Add os.O_WRONLY to icon.ico to avoid bad file descriptor error * Wrap errors coming from winres.LoadICO() If the file exists but is empty, a blunt "Unexpected EOF" is returned, and propagated as is. This is not super helpful when trying to pin point what's going on. Wrapping the error helps to locate the problem. --- v2/pkg/commands/build/packager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/pkg/commands/build/packager.go b/v2/pkg/commands/build/packager.go index fc6c1144a..9cf3ea47a 100644 --- a/v2/pkg/commands/build/packager.go +++ b/v2/pkg/commands/build/packager.go @@ -260,7 +260,7 @@ func generateIcoFile(options *Options) error { if err != nil { return err } - output, err := os.OpenFile(icoFile, os.O_CREATE, 0644) + output, err := os.OpenFile(icoFile, os.O_CREATE|os.O_WRONLY, 0644) if err != nil { return err } @@ -295,7 +295,7 @@ func compileResources(options *Options) error { defer iconFile.Close() ico, err := winres.LoadICO(iconFile) if err != nil { - return err + return fmt.Errorf("couldn't load icon from icon.ico: %w", err) } err = rs.SetIcon(winres.RT_ICON, ico) if err != nil {