fix(release): report a failed close and remove a partial asset

Re-lands !3562 (closed) by @ihopenre-eng on current main, since that MR went stale with conflicts. The commit keeps them as author.

glab release download dropped the error from closing the asset file and left a partial file behind when a download failed, so the next attempt failed with "file exists". The close error is now returned, and the file is removed on any failure.

Changes from !3562 (closed)
  • Resolved the conflict with the url.Parse check and the Markdown-upload download path that landed on main after !3562 (closed) was opened. The deferred cleanup covers both.
  • Test_downloadAsset_RemovesPartialFileOnErrorStatus is now table-driven and also covers the Markdown-upload path. Both cases fail with the os.Remove disabled.
  • A failed os.Remove is joined into the returned error, so a file that could not be cleaned up is reported instead of silently left behind.
  • Squashed the three commits into one and trimmed the comments.

Not covered by tests: the close-error half. Making *os.File.Close fail would need an interface seam, which is out of proportion for this change.

Closes #8429 (closed)

🤖 Generated with Claude Code

Edited by Jay McCure

Merge request reports

Loading
Loading