Skip to content

Commit

Permalink
Merge pull request #220 from CybercentreCanada/bugfix/rmdir_nonempty_…
Browse files Browse the repository at this point in the history
…directory

Fix rmdir on non-empty dir
  • Loading branch information
cccs-jh authored Jan 7, 2025
2 parents f3b7390 + 57cbd7f commit 33ad10f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions overpower/overpower.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,10 @@ def _prepare_artifacts(self, request: ServiceRequest, worth_extracting: bool = T
for root, dirs, _ in walk(getcwd()):
for d in dirs:
dir_path = path.join(root, d)
if len(listdir(dir_path)) == 0:
rmdir(dir_path)
try:
rmdir(dir_path) # Non-empty dir raises OSError
except OSError:
pass

# Retrieve artifacts
for root, _, files in walk(self.working_directory):
Expand Down

0 comments on commit 33ad10f

Please sign in to comment.