in ees_network_drive/deletion_sync_command.py [0:0]
def get_deleted_files(self, drive_name, ids):
"""Fetches the ids of deleted files from the Network Drives
:param drive_name: service name of the Network Drives
:param ids: structure containing id's of all files
Returns:
ids_list: list of file ids that got deleted from Network Drives
"""
file_details = ids["delete_keys"].get("files")
file_structure = group_files_by_folder_path(file_details)
ids_list = []
if not file_details:
self.logger.info(f"No files found to be deleted for drive: {drive_name}")
return []
deleted_folders = []
visited_folders = []
smb_connection = self.network_drive_client.connect()
if not smb_connection:
raise ConnectionError("Unknown error while connecting to network drives")
files = Files(self.logger, self.config, self.network_drive_client)
for file_id, file_path in file_details.items():
folder_path, file_name = os.path.split(file_path)
if folder_path in deleted_folders:
ids_list.append(file_id)
continue
if folder_path in visited_folders:
continue
folder_deleted = files.is_file_present_on_network_drive(
smb_connection,
drive_name,
folder_path,
file_structure,
ids_list,
visited_folders,
deleted_folders,
)
if folder_deleted:
ids_list.append(file_id)
return ids_list