Clean up temp dir if opening c1file results in an error.#698
Conversation
|
No actionable comments were generated in the recent review. 🎉 WalkthroughAdds an early validation rejecting negative Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant NewC1ZFile
participant UnderlyingC1File
participant OS as "OS/fs"
Caller->>NewC1ZFile: call NewC1ZFile(opts)
NewC1ZFile->>NewC1ZFile: apply options
NewC1ZFile-->>Caller: if encoderConcurrency < 0 → return error
NewC1ZFile->>UnderlyingC1File: attempt create/open
UnderlyingC1File-->>NewC1ZFile: error
NewC1ZFile->>OS: stat(dbFilePath)
alt path missing
OS-->>NewC1ZFile: ENOENT
NewC1ZFile-->>Caller: return original error
else path is directory
OS-->>NewC1ZFile: mode=dir
NewC1ZFile-->>Caller: return original error (skip cleanup)
else path is file
OS->>OS: remove parent temp dir
OS-->>NewC1ZFile: cleanup result
NewC1ZFile-->>Caller: return original error augmented with cleanup result (if any)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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 unit tests (beta)
Comment |
a759502 to
60efb87
Compare
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/dotc1z/c1file.go`:
- Around line 227-229: The validation for options.encoderConcurrency incorrectly
reports "must be greater than 0" while the check allows 0 (which is valid and
uses GOMAXPROCS); update the error message in the encoder concurrency check (the
code referencing options.encoderConcurrency in c1file.go) to state that the
value cannot be negative (e.g., "encoder concurrency must be >= 0" or "encoder
concurrency cannot be negative; 0 uses GOMAXPROCS") so it matches the validation
logic and comment.
- Around line 253-256: The call to cleanupDbDir is passing tmpDir (a directory)
but cleanupDbDir expects a file path and does filepath.Dir(), which would remove
the parent temp folder; change the error cleanup call in the NewC1File error
branch to pass dbFilePath instead of tmpDir (i.e., in the block after
NewC1File(ctx, dbFilePath, c1fopts...) where err != nil) so cleanupDbDir
receives the actual DB file path and removes the correct directory.
Summary by CodeRabbit