Repository navigation
fs: add uncancelable delete variants - #696
Conversation
Cleanup that a cancellation can skip leaves the file or directory behind for good, with nothing left to retry it. deleteFileUncancelable and deleteDirUncancelable run the unlink through waitForIoUncancelable, like close() does, and deleteTreeUncancelable walks the tree under a cancellation shield so a canceled task cannot abandon it half done. Each comes with an error set that has no Canceled in it, which is the point: a deinit handling error.Canceled from a delete either writes a branch that cannot be taken, or quietly reports a cancellation as a failed delete. DeleteTreeError is now that set plus Cancelable. The temporary file and directory cleanup paths were already doing this by hand, so removeTempTree is gone and removeTempFile is down to the log call it wraps; AtomicFile.deinit goes through the same helper.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe filesystem module adds uncancelable deletion APIs for files, directories, and trees. Temporary resource cleanup uses these APIs. Tests verify that cleanup completes while cancellation remains pending and is observed by the next cancelable wait. ChangesFilesystem cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR adds uncancelable delete operations for cleanup paths so cancellation cannot leave files or directories behind; no actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
deleteFile/deleteDir/deleteTreegain*Uncancelablesiblings, for the cleanup paths that must run even when the task is being canceled — a delete skipped by a cancellation leaves the file or directory behind for good, with nothing left to retry it.The two single-op ones go through
waitForIoUncancelable, the same primitiveclose()uses.deleteTreeUncancelablewalks the tree with many operations, so it runs under a cancellation shield instead, to keep a canceled task from abandoning it half done.Each has an error set with no
Canceledin it, which is the real point. Wrapping a delete inbeginShield()/endShield()already worked and is only two lines, but it leaveserror.Canceledin the signature, so every cleanup site either writes a branch that cannot be taken or quietly reports a cancellation as a failed delete.DeleteTreeErroris nowDeleteTreeUncancelableError || Cancelable.TempFile/TempDir/AtomicFilewere doing this by hand already:removeTempTreewas exactlydeleteTreeUncancelableand is gone, andremoveTempFileis down to thelog.warnit wraps.TempDir.CleanupErrordropsCanceledas a result.The test covers the contract that matters for a
deinit: with a cancellation pending, both deletes complete, and neither swallows the cancellation — it is still there for the next cancellation point. It self-cancels withgetCurrentTask().cancel()rather thanhandle.cancel(), which blocks until the task finishes.One thing that came up writing it: cancellation is delivered once (the
pending_errorscount), andWaiter.waitTaskreturns early without a cancel check when the signal already arrived, so a plaindeleteFilewith a cancel pending often succeeds anyway. It reportsCanceledonly when the op genuinely parks and the backend cancels it — intermittent rather than absent, which is the argument for having these.