feat: Refactor storage adapter and mount handling; migrate mounts to storage adapters; enhance SideNav; implement database migration scripts

This commit is contained in:
shiyu
2025-08-28 12:59:24 +08:00
parent bfa8898931
commit 62a1c5810d
16 changed files with 163 additions and 262 deletions
-3
View File
@@ -1,12 +1,9 @@
from .adapters import AdapterCreate, AdapterOut
from .mounts import MountCreate, MountOut
from .fs import MkdirRequest, MoveRequest
__all__ = [
"AdapterCreate",
"AdapterOut",
"MountCreate",
"MountOut",
"MkdirRequest",
"MoveRequest",
]
+8 -4
View File
@@ -2,13 +2,16 @@ from typing import Dict, Optional
from pydantic import BaseModel, Field, validator
class AdapterCreate(BaseModel):
class AdapterBase(BaseModel):
name: str
type: str = Field(pattern=r"^[a-zA-Z0-9_]+$")
config: Dict = Field(default_factory=dict)
enabled: bool = True
mount_path: str
sub_path: Optional[str] = None
sub_path: Optional[str] = None
class AdapterCreate(AdapterBase):
mount_path: str
@staticmethod
def normalize_mount_path(p: str) -> str:
@@ -25,8 +28,9 @@ class AdapterCreate(BaseModel):
return cls.normalize_mount_path(v)
class AdapterOut(AdapterCreate):
class AdapterOut(AdapterBase):
id: int
mount_path: str = Field(alias='path')
class Config:
from_attributes = True
-23
View File
@@ -1,23 +0,0 @@
from typing import Optional
from pydantic import BaseModel
class MountCreate(BaseModel):
path: str
adapter_id: int
sub_path: Optional[str] = None
enabled: bool = True
@staticmethod
def normalize(path: str) -> str:
return (path if path.startswith('/') else '/' + path).rstrip('/') or '/'
def model_post_init(self, __context):
self.path = self.normalize(self.path)
class MountOut(MountCreate):
id: int
class Config:
from_attributes = True