From 44277a35fb80e98c16c4bf4613e29717a9d77ec7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 18 Sep 2017 15:40:48 +0530 Subject: [PATCH] Delete backups if path exists --- frappe/utils/backups.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frappe/utils/backups.py b/frappe/utils/backups.py index d3a7b74ac4..845f4a623c 100644 --- a/frappe/utils/backups.py +++ b/frappe/utils/backups.py @@ -179,11 +179,13 @@ def delete_temp_backups(older_than=24): """ Cleans up the backup_link_path directory by deleting files older than 24 hours """ - file_list = os.listdir(get_backup_path()) - for this_file in file_list: - this_file_path = os.path.join(get_backup_path(), this_file) - if is_file_old(this_file_path, older_than): - os.remove(this_file_path) + backup_path = get_backup_path() + if os.path.exists(backup_path): + file_list = os.listdir(get_backup_path()) + for this_file in file_list: + this_file_path = os.path.join(get_backup_path(), this_file) + if is_file_old(this_file_path, older_than): + os.remove(this_file_path) def is_file_old(db_file_name, older_than=24): """