Skip to content

Conversation

@MatteoPologruto
Copy link
Contributor

@MatteoPologruto MatteoPologruto commented Nov 3, 2025

Motivation

The default download/extraction directory might be on a disk with insufficient space.

Change description

Two changes have been introduced:

  • allow the user to set a different temporary directory in which the Debian image is downloaded and/or extracted, using the --temp-dir flag;
  • check that the temporary directory is in a disk with enough free space before starting a download/extraction.

Additional Notes

Reviewer checklist

  • PR addresses a single concern.
  • PR title and description are properly filled.
  • Changes will be merged in main.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.

@MatteoPologruto MatteoPologruto self-assigned this Nov 3, 2025
@MatteoPologruto MatteoPologruto added the bug Something isn't working label Nov 3, 2025
per1234
per1234 previously requested changes Nov 3, 2025
@MatteoPologruto MatteoPologruto marked this pull request as ready for review November 3, 2025 16:22
@MatteoPologruto MatteoPologruto requested a review from a team November 3, 2025 16:22
Co-authored-by: Per Tillisch <accounts@perglass.com>
@per1234 per1234 dismissed their stale review November 3, 2025 16:26

Requested changes have been made. Thanks!

"github.com/arduino/arduino-flasher-cli/i18n"
)

const GB = uint64(1024 * 1024 * 1024)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const GB = uint64(1024 * 1024 * 1024)
const GiB = uint64(1024 * 1024 * 1024)

return nil, err
}
if d.Free/GB < NeededDiskSpace {
return nil, fmt.Errorf("aborting: download and extraction requires up to %d GB of free space", NeededDiskSpace)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, fmt.Errorf("aborting: download and extraction requires up to %d GB of free space", NeededDiskSpace)
return nil, fmt.Errorf("aborting: download and extraction requires up to %d GiB of free space", NeededDiskSpace)

if err != nil {
return nil, fmt.Errorf("could not get user's cache directory: %w", err)
}
func GetTempDir(prefix string, tempDir string) (*paths.Path, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is strange, in my opinion, that a function called GetTempDir has a parameter called tempDir. I think we should refactor this to make it cleaner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check available disk space before downloading/extracting images

3 participants