index multiple files concurrently
This commit is contained in:
@@ -1206,13 +1206,18 @@ def create_app(args):
|
|||||||
logging.error(f"Error deleting file {file_path}: {str(e)}")
|
logging.error(f"Error deleting file {file_path}: {str(e)}")
|
||||||
|
|
||||||
async def batch_index_files(file_paths: List[Path]):
|
async def batch_index_files(file_paths: List[Path]):
|
||||||
"""Index multiple files
|
"""Index multiple files concurrently
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
file_paths: Paths to the files to index
|
file_paths: Paths to the files to index
|
||||||
"""
|
"""
|
||||||
for file_path in file_paths:
|
if not file_paths:
|
||||||
await index_file(file_path)
|
return
|
||||||
|
if len(file_paths) == 1:
|
||||||
|
await index_file(file_paths[0])
|
||||||
|
else:
|
||||||
|
tasks = [index_file(path) for path in file_paths]
|
||||||
|
await asyncio.gather(*tasks)
|
||||||
|
|
||||||
async def save_temp_file(file: UploadFile = File(...)) -> Path:
|
async def save_temp_file(file: UploadFile = File(...)) -> Path:
|
||||||
"""Save the uploaded file to a temporary location
|
"""Save the uploaded file to a temporary location
|
||||||
|
Reference in New Issue
Block a user