Skip to content

Extract zip into temp dir to prevent leftover files on sudo cancel#13

Merged
albertodebortoli merged 2 commits intomainfrom
fix/extract-to-temp-dir
May 1, 2026
Merged

Extract zip into temp dir to prevent leftover files on sudo cancel#13
albertodebortoli merged 2 commits intomainfrom
fix/extract-to-temp-dir

Conversation

@albertodebortoli
Copy link
Copy Markdown
Member

@albertodebortoli albertodebortoli commented May 1, 2026

Summary

  • Downloads and extracts the Luca zip into a mktemp -d temp directory instead of the current working directory
  • Adds an EXIT trap (rm -rf "$TEMP_DIR") so the temp directory is always cleaned up, regardless of how the script exits
  • Removes the now-redundant manual rm of the zip file and the "Cleaned up temporary files" echo

Problem

When install.sh prompted for a sudo password (to mv the binary into /usr/local/bin) and the user cancelled, the extracted binary (Luca or luca) was left behind in whatever directory the script was run from.

Test plan

  • Run install.sh, cancel the sudo prompt → confirm no Luca/luca binary is left in CWD
  • Run install.sh normally → confirm Luca installs correctly to /usr/local/bin
  • Run install.sh again with same version → confirm the already-up-to-date early-exit path still works

If the user cancelled the sudo password prompt during installation, the
extracted binary was left behind in the current working directory. Using
a temp directory (mktemp -d) with an EXIT trap ensures all intermediate
files are cleaned up unconditionally regardless of how the script exits.
The mock was hardcoding ./Luca as the output path. Now it parses the
-d argument so it correctly places the binary in the temp directory
used by install.sh after the extraction refactor.
@albertodebortoli albertodebortoli marked this pull request as ready for review May 1, 2026 08:02
@albertodebortoli albertodebortoli merged commit 359b50d into main May 1, 2026
2 checks passed
@albertodebortoli albertodebortoli deleted the fix/extract-to-temp-dir branch May 1, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant