Skip to content

Commit

Permalink
Also move pr event dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
Neves-P committed Jul 1, 2024
1 parent f4114b3 commit 283f602
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion eessi_bot_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#

# Standard library imports
import os
import sys
from datetime import datetime, timezone

Expand Down Expand Up @@ -639,7 +640,7 @@ def handle_pull_request_closed_event(self, event_info, pr):

repo_name = request_body['repository']['full_name']
dt = datetime.now(timezone.utc)
trash_bin_dir = "/".join([trash_bin_root_dir, repo_name, dt.strftime('%Y%m.%d')])
trash_bin_dir = "/".join([trash_bin_root_dir, repo_name, dt.strftime('%Y.%m.%d')])

# Subdirectory with date of move. Also with repository name. Handle symbolic links (later?)
# cron job deletes symlinks?
Expand Down
10 changes: 10 additions & 0 deletions tasks/clean_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ def move_to_trash_bin(trash_bin_dir, job_dirs):
log(f"{funcname}(): trash_bin_dir = {trash_bin_dir}")

os.makedirs(trash_bin_dir, exist_ok=True)
pr_dirs = []
for job_dir in job_dirs:
destination_dir = shutil.move(job_dir, trash_bin_dir)
log(f"{funcname}(): moved {job_dir} to {destination_dir}")
# Save upper directory above to remove later (pr_xx)
pr_dirs = os.path.dirname(job_dir)

# Remove event_xxx-yyy/run_nnn/ directories
pr_dirs = list(set(pr_dirs))
for pr_dir in pr_dirs:
destination_dir = shutil.move(pr_dir, trash_bin_dir)
log(f"{funcname}(): moved {pr_dir} to {destination_dir}")

return True

0 comments on commit 283f602

Please sign in to comment.