fixed deleting old files
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user