Skip to content

Commit e0ff37f

Browse files
MK8S-25: Enhance index.html cleanup to remove empty directories
Fix "Cleanup build tree" failures by ensuring clean functions remove not just index.html files but also any empty parent directories created during index file creation. This prevents directory removal conflicts during the overall cleanup process. - Clean up index.html files first - Remove empty parent directories that were created for index files - Use safe directory removal with OSError handling - Ensures proper cleanup coordination between repository and packaging tasks
1 parent a01036c commit e0ff37f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

buildchain/buildchain/targets/repository.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,18 @@ def create_index_files(self) -> types.TaskDict:
273273

274274
def clean() -> None:
275275
"""Delete the index.html files created by this task."""
276-
# Actually remove the index.html files
276+
# Remove the index.html files
277277
for index_file in self._get_index_file_paths():
278278
if index_file.exists():
279279
index_file.unlink()
280+
# Also clean up any empty parent directories that we created
281+
for index_file in self._get_index_file_paths():
282+
parent_dir = index_file.parent
283+
if parent_dir.exists() and not any(parent_dir.iterdir()):
284+
try:
285+
parent_dir.rmdir()
286+
except OSError:
287+
pass # Directory not empty or doesn't exist, ignore
280288

281289
def create_index() -> None:
282290
"""Create empty index.html files in repository directories."""

0 commit comments

Comments
 (0)