mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-09-05 23:57:19 +08:00
feat: Refactor storage adapter and mount handling; migrate mounts to storage adapters; enhance SideNav; implement database migration scripts
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user