Skip to content

fix: Remove downloaded assets after use to prevent disk space leakage - #271

Merged
kalbasit merged 2 commits into
mainfrom
remove_temp_file_outside_download_fn
Aug 24, 2025
Merged

kalbasit merged 2 commits into
mainfrom
remove_temp_file_outside_download_fn

Conversation

@kalbasit

@kalbasit kalbasit commented Aug 24, 2025 •

Copy link
Copy Markdown
Owner

TL;DR

Added cleanup for temporary NAR files after download completion to prevent file system clutter.

What changed?

  • Enhanced the downloadState struct to include a sync.WaitGroup and assetPath field to track the temporary file
  • Modified the pullNarIntoStore function to:
    • Store the temporary file path in the download state
    • Wait for all readers to finish using the file before removal
    • Remove the temporary file asynchronously after download completion
  • Removed the immediate defer os.Remove() call that was previously used

How to test?

  1. Trigger multiple cache downloads in parallel
  2. Verify that temporary NAR files are properly cleaned up after downloads complete
  3. Check that no temporary files remain in the file system after operations finish

Why make this change?

The previous implementation immediately removed temporary files after download, which could cause issues if the file was still being processed. This change ensures proper cleanup of temporary NAR files only after they're no longer needed, preventing potential file system leaks while maintaining data integrity during concurrent operations.

@kalbasit
kalbasit marked this pull request as ready for review August 24, 2025 22:27
@kalbasit kalbasit changed the title remove the file only after all wg are done fix: Remove downloaded assets after use to prevent disk space leakage Aug 24, 2025
@kalbasit
kalbasit force-pushed the remove_temp_file_outside_download_fn branch from ba39f91 to 89cd2a9 Compare August 24, 2025 22:46
@kalbasit
kalbasit force-pushed the recognize_error_early branch 3 times, most recently from 05885c9 to 6f11c52 Compare August 24, 2025 22:53
@kalbasit
kalbasit force-pushed the remove_temp_file_outside_download_fn branch from 89cd2a9 to 03646b4 Compare August 24, 2025 22:53
@kalbasit
kalbasit force-pushed the recognize_error_early branch from 6f11c52 to 7aba5c1 Compare August 24, 2025 22:59
@kalbasit
kalbasit force-pushed the remove_temp_file_outside_download_fn branch from 03646b4 to 4eea1f6 Compare August 24, 2025 22:59
@kalbasit
kalbasit changed the base branch from recognize_error_early to graphite-base/271 August 24, 2025 23:09
@kalbasit
kalbasit force-pushed the remove_temp_file_outside_download_fn branch from 4eea1f6 to d4d29fc Compare August 24, 2025 23:09
@kalbasit
kalbasit changed the base branch from graphite-base/271 to main August 24, 2025 23:09
@kalbasit
kalbasit force-pushed the remove_temp_file_outside_download_fn branch from d4d29fc to 8e17203 Compare August 24, 2025 23:09
@kalbasit
kalbasit force-pushed the remove_temp_file_outside_download_fn branch from 8e17203 to 1823c8d Compare August 24, 2025 23:10
@kalbasit
kalbasit merged commit e2be50d into main Aug 24, 2025

Copy link
Copy Markdown
Owner Author

Merge activity

@kalbasit
kalbasit deleted the remove_temp_file_outside_download_fn branch August 24, 2025 23:18
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