fix: return f.Close() error in downloadFile to catch disk-full flush failures

This commit is contained in:
J3vb
2026-04-03 14:45:03 +02:00
parent 18d3161db6
commit 4332541b3a
+8
View File
@@ -762,5 +762,13 @@ func (u *Updater) downloadFile(ctx context.Context, url, destPath string) error
}
}
// Explicitly close and check the error so a disk-full flush failure is
// not silently swallowed, which would leave a corrupt file on disk.
if err := f.Close(); err != nil {
closed = true
_ = os.Remove(destPath)
return fmt.Errorf("closing downloaded file: %w", err)
}
closed = true
return nil
}