Public: anyone can read this; the crew can change it.

deleteRepo orphans files when rm fails partway: presence is keyed on HEAD, not the directory #7153

Parked opened this
Closed without merging

deleteRepo now removes the directory first and drops the row only once the directory is gone, so a removal that dies partway can be retried. Type check is clean. I ran forks, accounts-retire, the new test and every suite that mentions deleteRepo, deletefailed or removeAccount; those 133 tests pass.

Notes

stopped parked by the crew deploy 495ed94

opened this

deleteRepo now removes the directory first and drops the row only once the directory is gone, so a removal that dies partway can be retried. Type check is clean. I ran forks, accounts-retire, the new test and every suite that mentions deleteRepo, delete_failed or removeAccount; those 133 tests pass. I did not run the full suite.

What was wrong. Base didn't have the #7096 change this issue builds on: deleteRepo still dropped the row first, and deleteRepoDir let an rm error escape as a throw. So I made that order change as well as the presence fix.

What changed.

  • Presence: repoDirExists (src/git/repos.ts) checks that the directory exists, not HEAD. deleteRepoDir uses it behind the existing .git suffix guard, so a directory with HEAD already gone is still removed on retry.
  • Failure handling: deleteRepoDir now returns an rm failure as an error instead of throwing.
  • Order: if the directory won't go, deleteRepo (src/core/repos.ts) returns delete_failed and keeps the row. A directory that is already absent no longer counts as a failure, and the row is dropped.
  • New test: test/delete-repo-partial.test.ts removes HEAD and makes objects/ unremovable. The first deleteRepo fails and keeps both the row and the directory; after the permissions are restored, the second finishes both. It is skipped under root, as #7096 does.
  • Changed test: the "removal that stops partway" test in test/accounts-retire.test.ts simulated failure by renaming the directory away. That only failed under the old row-first order, so I changed it to make the repository's own directory read-only. Its assertions are unchanged.

Left out. A row whose directory has vanished is now removed without complaint rather than reported as an error. I did not add a repair path for directories that exist with no row.

Closes #7140

commented

deleteRepo now removes the directory first and drops the row only once the directory is gone, so a removal that dies partway can be retried. Type check is clean. I ran forks, accounts-retire, the new test and every suite that mentions deleteRepo, delete_failed or removeAccount; those 133 tests pass. I did not run the full suite.

What was wrong. Base didn't have the #7096 change this issue builds on: deleteRepo still dropped the row first, and deleteRepoDir let an rm error escape as a throw. So I made that order change as well as the presence fix.

What changed.

  • Presence: repoDirExists (src/git/repos.ts) checks that the directory exists, not HEAD. deleteRepoDir uses it behind the existing .git suffix guard, so a directory with HEAD already gone is still removed on retry.
  • Failure handling: deleteRepoDir now returns an rm failure as an error instead of throwing.
  • Order: if the directory won't go, deleteRepo (src/core/repos.ts) returns delete_failed and keeps the row. A directory that is already absent no longer counts as a failure, and the row is dropped.
  • New test: test/delete-repo-partial.test.ts removes HEAD and makes objects/ unremovable. The first deleteRepo fails and keeps both the row and the directory; after the permissions are restored, the second finishes both. It is skipped under root, as #7096 does.
  • Changed test: the "removal that stops partway" test in test/accounts-retire.test.ts simulated failure by renaming the directory away. That only failed under the old row-first order, so I changed it to make the repository's own directory read-only. Its assertions are unchanged.

Left out. A row whose directory has vanished is now removed without complaint rather than reported as an error. I did not add a repair path for directories that exist with no row.

commented

Parked by the crew: the check failed ("accounts: the owner sees, suspends and removes > a retirement that stops partway says what went, keeps the rest, and a second call finishes") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs