fix: rename temp downloaded file to given cache path#332
Conversation
resolves #330 This simply keeps the downloaded temp file in the same directory as the destination of the downloaded file. When download is done, the file is renamed to the specified file name. This also removes the `tempfile` dependency from production code. It is still used heavily in tests.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughRefactors clang-installer download flow to write to a deterministic temp path and atomically persist via fs::rename while mapping IO errors to a new ChangesTemporary file handling refactor
CI workflow trigger update
🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@clang-installer/src/downloader/mod.rs`:
- Line 61: The temp path creation uses cache_path.with_extension("tmp") which
replaces the last dot-segment and drops version info; instead construct
tmp_file_path by appending ".tmp" to the full file name (use
cache_path.file_name() to get the complete name and
cache_path.with_file_name(...) to build a new PathBuf), so the versioned
filenames like "clang-format-18.1.8" become "clang-format-18.1.8.tmp" and avoid
collisions; update the code that sets tmp_file_path accordingly (reference
tmp_file_path, cache_path.with_extension, cache_path.file_name,
cache_path.with_file_name).
- Around line 89-92: The temp file is not closed before fs::rename and is never
cleaned up on errors; modify the download flow around
tmp_file/tmp_file_path/cache_path so you drop/close tmp_file (e.g.,
drop(tmp_file) or let tmp_file go out of scope) before calling
fs::rename(cache_path) to avoid Windows share issues, and ensure the
tmp_file_path is removed on any error/early return (or replace the manual tmp
logic with tempfile::NamedTempFile and use its persist method to atomically move
into cache_path, mapping persist errors into DownloadError::TempFile); update
error handling paths to remove the *.tmp placeholder when failures occur.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1aba07b3-51a5-4b15-a150-6c731e2ad05a
📒 Files selected for processing (2)
clang-installer/Cargo.tomlclang-installer/src/downloader/mod.rs
run CI tests on installer crate too
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #332 +/- ##
==========================================
- Coverage 90.94% 90.91% -0.04%
==========================================
Files 22 22
Lines 3368 3378 +10
==========================================
+ Hits 3063 3071 +8
- Misses 305 307 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
resolves #330
This simply keeps the downloaded temp file in the same directory as the destination of the downloaded file. When download is done, the file is renamed to the specified file name.
This also removes the
tempfiledependency from production code. It is still used heavily in tests.Summary by CodeRabbit
Bug Fixes
Breaking Changes
Chores