in ees_network_drive/files.py [0:0]
def fetch_files(self, service_name, path_list, time_range, indexing_rules):
"""This method is used to fetch and index files to Workplace Search
:param service_name: name of the drive
:param path_list: list of folder paths inside the network drives
:param time_range: Start and End Time
:param indexing_rules: object of indexing_rules
"""
schema = adapter.FILES
documents = []
smb_connection = self.network_drives_client.connect()
if smb_connection:
for folder_path in path_list:
storage = self.extract_files(smb_connection, service_name, folder_path, time_range, indexing_rules)
for file_id, file_details in storage.items():
doc = {}
for field, file_field in schema.items():
doc[field] = file_details.get(file_field)
doc.update({'body': {}, 'id': str(file_id)})
if self.enable_document_permission:
permissions = self.retrieve_permission(
smb_connection, service_name, file_details.get("file_path"))
doc['_allow_permissions'] = permissions['allow']
doc['_deny_permissions'] = permissions['deny']
doc['body'] = self.fetch_file_content(service_name, file_details, smb_connection)
documents.append(doc)
smb_connection.close()
else:
raise ConnectionError("Unknown error while connecting to network drives")
return documents