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!

Run: func(cmd *cobra.Command, args []string) {
checkDriversInstalled()
runFlashCommand(cmd.Context(), args, forceYes)
runFlashCommand(cmd.Context(), args, forceYes, tempDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to handle the tmpDir definition directly here. You can check if tempDir is set, and if not, you can use the .cache folder as the default one

const DownloadDiskSpace = uint64(12)
const ExtractDiskSpace = uint64(10)

func Flash(ctx context.Context, imagePath *paths.Path, version string, forceYes bool, tempDir string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect that the flash function will just flash and not download the image, Can you move the

if !imagePath.Exist() 

Inside the function runFlashCommand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason behind this is that

defer func() { _ = temp.RemoveAll() }()

does not seem to work properly if executed directly into runFlashCommand. There were many cases in which the files were not correctly removed. I can either rename this Flash function or do some more refactoring, but I would keep the runFlashCommand as a wrapper that just handles feedback to the user.

Comment on lines +33 to +34
const DownloadDiskSpace = uint64(12)
const ExtractDiskSpace = uint64(10)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would keep two values. One for only the estimated archive size and another for the extract size

Suggested change
const DownloadDiskSpace = uint64(12)
const ExtractDiskSpace = uint64(10)
const EstimatedDownloadSize = uint64(2) * GiB
const EstimateExtractionSize = uint64(10) * GiB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the image is not local, it is always downloaded and extracted. I don't think there is a need to keep them as separated values, since we would need the sum of the two anyway

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