Refactoring of services.py; tests
This commit is contained in:
42
server/app/storage/common.py
Normal file
42
server/app/storage/common.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from app.db.models import FileAsset, FileBlob, FileVersion
|
||||
|
||||
|
||||
class FileStorageError(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class UploadedStoredFile:
|
||||
asset: FileAsset
|
||||
version: FileVersion
|
||||
blob: FileBlob
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class ResolvedPattern:
|
||||
pattern: str
|
||||
matches: list[FileAsset]
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class FileConflictResolution:
|
||||
target_path: str
|
||||
action: str
|
||||
new_path: str | None = None
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class RenamePlanItem:
|
||||
kind: str
|
||||
id: str
|
||||
old_path: str
|
||||
new_path: str
|
||||
|
||||
|
||||
def utcnow() -> datetime:
|
||||
return datetime.now(timezone.utc)
|
||||
Reference in New Issue
Block a user