fix(release): retry plugin cleanup during bundle sync

Handle transient ENOTEMPTY failures when rebuilding root and bundle plugin skill directories during the release sync flow, and cover the retry behavior with a unit test.
This commit is contained in:
sickn33
2026-03-30 21:32:29 +02:00
parent 9bb2ff6a3a
commit d03a20af42
2 changed files with 38 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
import importlib.util
import errno
import pathlib
import sys
from unittest import mock
import unittest
@@ -142,6 +144,22 @@ class EditorialBundlesTests(unittest.TestCase):
f"Claude root plugin inclusion mismatch for {skill_id}",
)
def test_remove_tree_retries_on_enotempty(self):
target = REPO_ROOT / "plugins" / "antigravity-awesome-skills" / "skills"
calls = {"count": 0}
def flaky_rmtree(path):
calls["count"] += 1
if calls["count"] == 1:
raise OSError(errno.ENOTEMPTY, "Directory not empty")
with mock.patch.object(editorial_bundles.shutil, "rmtree", side_effect=flaky_rmtree):
with mock.patch.object(editorial_bundles.time, "sleep") as sleep_mock:
editorial_bundles._remove_tree(target)
self.assertEqual(calls["count"], 2)
sleep_mock.assert_called_once()
if __name__ == "__main__":
unittest.main()