mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-03 10:48:35 +08:00
add storage snapshot
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from pathlib import Path
|
||||
from typing import Optional, Tuple, List
|
||||
from typing import Optional, Tuple, List, Dict
|
||||
|
||||
from app import schemas
|
||||
from app.chain import ChainBase
|
||||
@@ -57,3 +57,9 @@ class StorageChain(ChainBase):
|
||||
重命名文件或目录
|
||||
"""
|
||||
return self.run_module("rename_file", fileitem=fileitem, name=name)
|
||||
|
||||
def snapshot_storage(self, fileitem: schemas.FileItem) -> Optional[Dict]:
|
||||
"""
|
||||
快照存储
|
||||
"""
|
||||
return self.run_module("snapshot_storage", fileitem=fileitem)
|
||||
|
||||
@@ -173,6 +173,16 @@ class FileManagerModule(_ModuleBase):
|
||||
return None
|
||||
return storage_oper.upload(fileitem, path)
|
||||
|
||||
def snapshot_storage(self, fileitem: FileItem) -> Optional[Dict]:
|
||||
"""
|
||||
快照存储
|
||||
"""
|
||||
storage_oper = self.__get_storage_oper(fileitem.storage)
|
||||
if not storage_oper:
|
||||
logger.error(f"不支持 {storage} 的快照处理")
|
||||
return None
|
||||
return storage_oper.snapshot(fileitem)
|
||||
|
||||
def transfer(self, fileitem: FileItem, meta: MetaBase, mediainfo: MediaInfo,
|
||||
transfer_type: str, target_storage: str = None, target_path: Path = None,
|
||||
episodes_info: List[TmdbEpisode] = None,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from pathlib import Path
|
||||
from typing import Optional, List, Union
|
||||
from typing import Optional, List, Union, Dict
|
||||
|
||||
from app import schemas
|
||||
from app.helper.storage import StorageHelper
|
||||
@@ -137,4 +137,23 @@ class StorageBase(metaclass=ABCMeta):
|
||||
软链接文件
|
||||
"""
|
||||
pass
|
||||
|
||||
def snapshot(self, fileitm: schemas.FileItem) -> Dict[str, float]:
|
||||
"""
|
||||
快照文件系统,输出所有层级文件信息
|
||||
"""
|
||||
files_info = {}
|
||||
|
||||
def __snapshot_file(_fileitm: schemas.FileItem):
|
||||
"""
|
||||
递归获取文件信息
|
||||
"""
|
||||
files_info[_fileitm.path] = _fileitm.size
|
||||
if _fileitm.type == "dir":
|
||||
for sub_file in self.list(_fileitm):
|
||||
__snapshot_file(sub_file)
|
||||
|
||||
__snapshot_file(fileitm)
|
||||
|
||||
return files_info
|
||||
|
||||
@@ -494,6 +494,7 @@ class AliPan(StorageBase):
|
||||
"""
|
||||
获取文件或目录,不存在返回None
|
||||
"""
|
||||
|
||||
def __find_item(_fileitem: schemas.FileItem, _name: str) -> Optional[schemas.FileItem]:
|
||||
"""
|
||||
查找下级目录中匹配名称的目录或文件
|
||||
|
||||
Reference in New Issue
Block a user