mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 18:58:48 +08:00
BUG: fixed removing files- check the path, not the file
This commit is contained in:
@@ -446,12 +446,13 @@ def remove_old_files(algo_name, today, rel_path, environ=None):
|
||||
# run on all files in the folder
|
||||
for f in os.listdir(folder):
|
||||
try:
|
||||
creation_unix = os.path.getctime(os.path.join(folder, f))
|
||||
creation_time = pd.to_datetime(creation_unix, unit='s', )
|
||||
file_path = os.path.join(folder, f)
|
||||
creation_unix = os.path.getctime(file_path)
|
||||
creation_time = pd.to_datetime(creation_unix, unit='s', utc=True)
|
||||
|
||||
# if the file is older than 30 days erase it
|
||||
if today - pd.DateOffset(30) > creation_time:
|
||||
os.unlink(f)
|
||||
os.unlink(file_path)
|
||||
except OSError:
|
||||
error = 'unable to erase files in {}'.format(folder)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user