BUG: fixed removing files- check the path, not the file

This commit is contained in:
AvishaiW
2018-03-01 09:42:07 +02:00
parent b85219d5b4
commit 6c4f7afaea
+4 -3
View File
@@ -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)