Skip to content

Commit

Permalink
Merge pull request #2777 from Aqr-K/dev-transtype
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp authored Sep 26, 2024
2 parents 46fb52f + 255c05d commit 1a36d9f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
11 changes: 11 additions & 0 deletions app/api/endpoints/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,14 @@ def usage(name: str, _: User = Depends(get_current_active_superuser)) -> Any:
if ret:
return ret
return schemas.StorageUsage()


@router.get("/transtype/{name}", summary="支持的整理方式获取", response_model=schemas.StorageTransType)
def transtype(name: str, _: User = Depends(get_current_active_superuser)) -> Any:
"""
查询支持的整理方式
"""
ret = StorageChain().support_transtype(name)
if ret:
return schemas.StorageTransType(transtype=ret)
return schemas.StorageTransType()
6 changes: 6 additions & 0 deletions app/chain/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,9 @@ def storage_usage(self, storage: str) -> Optional[schemas.StorageUsage]:
存储使用情况
"""
return self.run_module("storage_usage", storage=storage)

def support_transtype(self, storage: str) -> Optional[str]:
"""
获取支持的整理方式
"""
return self.run_module("support_transtype", storage=storage)
10 changes: 10 additions & 0 deletions app/modules/filemanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ def test(self) -> Tuple[bool, str]:
def init_setting(self) -> Tuple[str, Union[str, bool]]:
pass

def support_transtype(self, storage: str) -> Optional[Dict[str, str]]:
"""
支持的整理方式
"""
storage_oper = self.__get_storage_oper(storage)
if not storage_oper:
logger.error(f"不支持 {storage} 的整理方式获取")
return None
return storage_oper.support_transtype()

def recommend_name(self, meta: MetaBase, mediainfo: MediaInfo) -> Optional[str]:
"""
获取重命名后的名称
Expand Down
4 changes: 2 additions & 2 deletions app/modules/filemanager/storages/u115.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __credential(self) -> Optional[Credential]:
return None
return Credential.from_dict(cookie_dict.dict().get("config"))

def __save_credentail(self, credential: Credential):
def __save_credential(self, credential: Credential):
"""
设置115认证参数
"""
Expand Down Expand Up @@ -117,7 +117,7 @@ def check_login(self) -> Optional[Tuple[dict, str]]:
status = self.cloud.qrcode_poll(self._session)
if status == QrcodeStatus.Done:
# 确认完成,保存认证信息
self.__save_credentail(self.cloud.export_credentail())
self.__save_credential(self.cloud.export_credentail())
result = {
"status": 1,
"tip": "登录成功!"
Expand Down
5 changes: 5 additions & 0 deletions app/schemas/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ class StorageUsage(BaseModel):
total: float = 0.0
# 剩余空间
available: float = 0.0


class StorageTransType(BaseModel):
# 传输类型
transtype: Optional[dict] = {}

0 comments on commit 1a36d9f

Please sign in to comment.