chore: 502 bei propfind-fail, min_length path, exact-call assertion
This commit is contained in:
25
app/bulk.py
25
app/bulk.py
@@ -4,8 +4,8 @@ from pathlib import PurePosixPath
|
||||
from urllib.parse import unquote
|
||||
|
||||
import httpx
|
||||
from fastapi import APIRouter, BackgroundTasks, Header, status
|
||||
from pydantic import BaseModel
|
||||
from fastapi import APIRouter, BackgroundTasks, Header, HTTPException, status
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.config import get_settings
|
||||
from app.ingest.extractors import SUPPORTED_TYPES
|
||||
@@ -19,7 +19,7 @@ router = APIRouter()
|
||||
|
||||
|
||||
class BulkRequest(BaseModel):
|
||||
path: str
|
||||
path: str = Field(min_length=1)
|
||||
|
||||
|
||||
PROPFIND_BODY = """<?xml version="1.0"?>
|
||||
@@ -74,12 +74,19 @@ async def bulk_import(
|
||||
settings = get_settings()
|
||||
verify_secret(x_webhook_secret, settings.webhook_secret)
|
||||
|
||||
files = await list_files_recursive(
|
||||
settings.nextcloud_webdav_url,
|
||||
settings.nextcloud_user,
|
||||
settings.nextcloud_app_password,
|
||||
body.path,
|
||||
)
|
||||
try:
|
||||
files = await list_files_recursive(
|
||||
settings.nextcloud_webdav_url,
|
||||
settings.nextcloud_user,
|
||||
settings.nextcloud_app_password,
|
||||
body.path,
|
||||
)
|
||||
except (RuntimeError, httpx.HTTPError, ET.ParseError) as exc:
|
||||
logger.exception(
|
||||
"bulk listing failed",
|
||||
extra={"event": "bulk_listing_failed", "path": body.path, "error": str(exc)},
|
||||
)
|
||||
raise HTTPException(status_code=502, detail="webdav listing failed") from exc
|
||||
|
||||
dispatched = 0
|
||||
for f in files:
|
||||
|
||||
Reference in New Issue
Block a user