Commit c11455af by Javier

Anyado funcion para verificar que la backups a borrar sea correcta

parent 31fcfedf
...@@ -47,6 +47,9 @@ def delete_file_date(): ...@@ -47,6 +47,9 @@ def delete_file_date():
for item in folder_info["metadata"]["contents"]: #Recorro los ficheros de la carpeta for item in folder_info["metadata"]["contents"]: #Recorro los ficheros de la carpeta
file_time = item["created"] file_time = item["created"]
if compare_date_file(file_time): #Si la fecha del fichero es anterior a 30 dias de antiguedad if compare_date_file(file_time): #Si la fecha del fichero es anterior a 30 dias de antiguedad
#Compruebo que el fichero que vamos a borrar pertenece a dentro de la ruta folder_path
item_path = item['path']
if comprobar_item_a_borrar(item_path, folder_path):
#Borar fichero #Borar fichero
pc.deletefile(fileid=item["fileid"]) pc.deletefile(fileid=item["fileid"])
deletes_files.append(item["name"]) deletes_files.append(item["name"])
...@@ -73,3 +76,15 @@ def compare_date_file(file_time_create: str): ...@@ -73,3 +76,15 @@ def compare_date_file(file_time_create: str):
else: else:
return False return False
def comprobar_item_a_borrar(item_path: str, folder_path: str):
"""Para asegurarnos que no se borre el directorio raiz de PCloud donde se almacenan las backups, comprobamos que el fichero que se borre pertenezca
al interior de la ruta del directorio raiz(folder_path).
Params:
item_path: Path de almacenamiento del fichero de backups que vamos a borrar en Pcloud, este path me lo proporciona la busqueda de ficheros\
en un directorio.
folder_path: Path absoluta donde debería de estar ese fichero almacenado en Pcloud.
"""
if folder_path in item_path:
return True
else:
return False
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment