perf(daemon): skip service binary copy when unchanged#654
Conversation
Compare source and destination binaries before copying in prepareBinary. Uses a size pre-filter followed by streaming byte comparison to avoid unnecessary writes on SD card devices where write wear and speed are concerns.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded a file-comparison helper Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/service/daemon/daemon_test.go`:
- Around line 190-198: In TestFilesEqual_TargetMissing and
TestFilesEqual_SourceMissing replace hardcoded absolute paths with temp-dir
based paths: use t.TempDir() combined with filepath.Join to create non-existent
paths (e.g., filepath.Join(t.TempDir(), "does-not-exist", "file")) instead of
"/nonexistent/file" and create distinct TempDir()-based paths for both arguments
in filesEqual calls; update the calls to filesEqual in these tests (functions
TestFilesEqual_TargetMissing and TestFilesEqual_SourceMissing) to use those
filepath.Join(t.TempDir(), ...) values to ensure cross-platform compatibility.
In `@pkg/service/daemon/daemon.go`:
- Around line 224-276: Update filesEqual to accept an afero.Fs parameter and
replace all direct os.Stat/os.Open calls with the afero equivalents (use
fs.Stat, afero.Open or afero.ReadFile/Reader helpers) so the function signature
becomes filesEqual(fs afero.Fs, pathA, pathB string) (bool, error); update every
call site that invokes filesEqual in this package to pass afero.NewOsFs() in
production code and inject test filesystems (e.g., afero.NewMemMapFs()) in
tests, ensuring error handling and defer Close semantics remain identical.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 294fb681-501e-4fe6-8db6-449246d8bd82
📒 Files selected for processing (2)
pkg/service/daemon/daemon.gopkg/service/daemon/daemon_test.go
Use filepath.Join(t.TempDir(), ...) instead of hardcoded absolute paths like "/nonexistent/file" for cross-platform compatibility.
Summary
prepareBinaryto avoid unnecessary writes on SD card devicesSummary by CodeRabbit
New Features
Tests