feat(sources): local_folder source backend + import pipeline
First ingest path beyond manual upload (plan §1C). Source abstraction +
the first concrete backend, so a homelab can index an existing library.
- domain: SourceBackend/IndexableSource ports + SourceInfo/SourceFile shapes
- infrastructure/sources: LocalFolderSource (walks a mounted dir, idempotent
source_id = relative path) + registry built from settings
- application: LibraryImportService — batch sibling of UploadService; dedup on
(source, source_id), copy into storage, minimal track (metadata_status=pending,
enrichment fills the rest in 1D), per-file failures isolated
- workers: scan_local_folder arq task (registered) + enqueue helper (503 if
Redis down)
- api: GET /sources, POST /sources/{source}/scan (admin, enqueues), /health
- config: LOCAL_MEDIA_IMPORT_PATH; README + .env.example documented
- tests: scanner, registry, import service (fakes) + DB-gated sources API path
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Schemas for the source endpoints."""
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.domain.sources import SourceInfo
|
||||
|
||||
|
||||
class SourceInfoOut(BaseModel):
|
||||
name: str
|
||||
label: str
|
||||
kind: str
|
||||
available: bool
|
||||
|
||||
@classmethod
|
||||
def from_entity(cls, info: SourceInfo) -> SourceInfoOut:
|
||||
return cls(name=info.name, label=info.label, kind=info.kind, available=info.available)
|
||||
|
||||
|
||||
class ScanResponse(BaseModel):
|
||||
"""Result of enqueuing a source scan."""
|
||||
|
||||
source: str
|
||||
job_id: str
|
||||
status: str = "queued"
|
||||
|
||||
|
||||
class SourceHealthOut(BaseModel):
|
||||
name: str
|
||||
available: bool
|
||||
Reference in New Issue
Block a user