Align knowledge storage with real folders and add WebDAV import surface
Knowledge files were only partitioned in the database, which made nested uploads, local folder visibility, and delete behavior diverge from the UI. This change makes folder selection drive physical storage paths, keeps original filenames, adds a minimal WebDAV mount/sync path, and reshapes the knowledge panel so local and remote sources can share the same surface. Constraint: Existing knowledge flow already depends on local-folder-backed uploads and document indexing Rejected: Real-time bidirectional WebDAV sync | too much conflict and lifecycle complexity for the first pass Confidence: medium Scope-risk: moderate Reversibility: messy Directive: Keep remote mounts single-direction into local knowledge folders until etag-based incremental sync and conflict rules are verified Tested: Python py_compile on new/modified backend files; LSP diagnostics on new frontend/backend files; manual targeted code-path inspection Not-tested: Full pytest/vitest end-to-end runs blocked by environment temp/cache permission errors; live WebDAV server interoperability
This commit is contained in:
58
backend/app/schemas/remote_mount.py
Normal file
58
backend/app/schemas/remote_mount.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, Field, HttpUrl
|
||||
|
||||
|
||||
class RemoteMountCreate(BaseModel):
|
||||
name: str = Field(..., min_length=1, max_length=255)
|
||||
base_url: HttpUrl
|
||||
username: str | None = Field(default=None, max_length=255)
|
||||
password: str | None = Field(default=None, max_length=2000)
|
||||
root_path: str = Field(default="/", min_length=1, max_length=1000)
|
||||
|
||||
|
||||
class RemoteMountOut(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
mount_type: str
|
||||
base_url: str
|
||||
username: str | None
|
||||
root_path: str
|
||||
is_active: bool
|
||||
last_sync_at: str | None
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class RemoteNodeOut(BaseModel):
|
||||
path: str
|
||||
name: str
|
||||
is_dir: bool
|
||||
size: int | None = None
|
||||
modified_at: str | None = None
|
||||
etag: str | None = None
|
||||
children: list["RemoteNodeOut"] = []
|
||||
|
||||
|
||||
class RemoteMountTreeOut(BaseModel):
|
||||
mount_id: str
|
||||
root_path: str
|
||||
nodes: list[RemoteNodeOut]
|
||||
|
||||
|
||||
class RemoteSyncRequest(BaseModel):
|
||||
remote_path: str = Field(..., min_length=1, max_length=2000)
|
||||
local_folder_id: str = Field(..., min_length=1, max_length=36)
|
||||
mode: str = Field(default="file", pattern="^(file|folder)$")
|
||||
|
||||
|
||||
class RemoteSyncResultOut(BaseModel):
|
||||
synced: int
|
||||
skipped: int
|
||||
failed: int
|
||||
document_ids: list[str]
|
||||
errors: list[str]
|
||||
|
||||
|
||||
RemoteNodeOut.model_rebuild()
|
||||
Reference in New Issue
Block a user