fixed deleting old files

This commit is contained in:
christian
2021-11-15 21:42:34 +01:00
parent 33749c149c
commit bd8b63bc8d
2 changed files with 13 additions and 7 deletions
+9 -5
View File
@@ -180,11 +180,16 @@ class sftp_remote:
self.delete_file(last_modified, pathfile, 45)
self.disconnect()
def delete_remote_zips(self, zip_file_path):
def delete_remote_zips(self, backups_dir):
self.connect()
if zip_file_path.endswith(".zip"):
pathfile, last_modified = self.change_path(zip_file_path)
self.delete_file(last_modified, pathfile, 10)
for directories in self.sftp.listdir(backups_dir):
for files in self.sftp.listdir(f'{backups_dir}/{directories}'):
pathfile = f'{backups_dir}/{directories}/{files}'
if not pathfile.endswith(".zip"):
continue
utime = self.sftp.stat(pathfile).st_mtime
last_modified = datetime.fromtimestamp(utime)
self.delete_file(last_modified, pathfile, 10)
self.disconnect()
def delete_remote_zip_temp(self, zipname):
@@ -195,4 +200,3 @@ class sftp_remote:
def delete_local_zip(self, local_zip_path_name):
os.remove(local_zip_path_name)