Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk space checks should come earlier and use MB in the message #889

Merged
merged 5 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,19 @@ elif [ "$FORCE" = "1" ] && [ -e "$PREFIX" ]; then
REINSTALL=1
fi

total_installation_size_kb="__TOTAL_INSTALLATION_SIZE_KB__"
total_installation_size_mb="$(( total_installation_size_kb / 1024 ))"
if ! mkdir -p "$PREFIX"; then
printf "ERROR: Could not create directory: '%s'\\n" "$PREFIX" >&2
printf "ERROR: Could not create directory: '%s'.\\n" "$PREFIX" >&2
printf "Check permissions and available disk space (%s MB needed).\\n" "$total_installation_size_mb" >&2
exit 1
fi

total_installation_size_kb="__TOTAL_INSTALLATION_SIZE_KB__"
free_disk_space_bytes="$(df -Pk "$PREFIX" | tail -n 1 | awk '{print $4}')"
free_disk_space_kb="$((free_disk_space_bytes / 1024))"
free_disk_space_kb_with_buffer="$((free_disk_space_bytes - 100 * 1024))" # add 100MB of buffer
free_disk_space_kb="$(df -Pk "$PREFIX" | tail -n 1 | awk '{print $4}')"
free_disk_space_kb_with_buffer="$((free_disk_space_kb - 50 * 1024))" # add 50MB of buffer
if [ "$free_disk_space_kb_with_buffer" -lt "$total_installation_size_kb" ]; then
printf "ERROR: Not enough free disk space: %s < %s\\n" "$free_disk_space_kb_with_buffer" "$total_installation_size_kb" >&2
printf "ERROR: Not enough free disk space. Only %s MB are available, but %s MB are required (leaving a 50 MB buffer).\\n" \
"$((free_disk_space_kb_with_buffer / 1024))" "$total_installation_size_mb" >&2
exit 1
fi

Expand Down
19 changes: 19 additions & 0 deletions news/889-disk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Perform disk space checks earlier and report errors in MB (`.sh` installers only). (#778 via 889)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
Loading