Skip to content

Commit

Permalink
Do not delete all jobs dirs.
Browse files Browse the repository at this point in the history
The condition was always true because file mtime is less then current time
and "mtime - now" is negative.
  • Loading branch information
sorlov-rh committed Mar 4, 2021
1 parent 96879fa commit 7f83d57
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion autocleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ def get_old_job_dirs(max_days):
"""
old_job_dirs = []
max_days = datetime.timedelta(max_days)
now = datetime.datetime.now()
for folder in os.scandir(JOBS_DIR):
if folder.is_dir():
mtime = datetime.datetime.fromtimestamp(
os.path.getmtime(folder.path))
if mtime - datetime.datetime.now() < max_days:
if now - mtime < max_days:
old_job_dirs.append(folder.path)
return old_job_dirs

Expand Down

0 comments on commit 7f83d57

Please sign in to comment.