BUG #252 fixed utc time and file erased

This commit is contained in:
Avishai Weingarten
2018-02-27 09:47:02 +02:00
committed by GitHub
parent e5870ea60a
commit cfafafb8fc
+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)