diff --git a/app/api/endpoints/history.py b/app/api/endpoints/history.py index 8b297172..c3693b94 100644 --- a/app/api/endpoints/history.py +++ b/app/api/endpoints/history.py @@ -91,9 +91,7 @@ def delete_transfer_history(history_in: schemas.TransferHistory, # 册除媒体库文件 if deletedest and history.dest_fileitem: dest_fileitem = schemas.FileItem(**history.dest_fileitem) - state = StorageChain().delete_media_file(fileitem=dest_fileitem, mtype=MediaType(history.type)) - if not state: - return schemas.Response(success=False, message=f"{dest_fileitem.path} 删除失败") + StorageChain().delete_media_file(fileitem=dest_fileitem, mtype=MediaType(history.type)) # 删除源文件 if deletesrc and history.src_fileitem: diff --git a/app/chain/transfer.py b/app/chain/transfer.py index 44372148..598236ee 100644 --- a/app/chain/transfer.py +++ b/app/chain/transfer.py @@ -49,7 +49,7 @@ class JobManager: "tasks": [ { "fileitem": schema.FileItem, - "meta": schema.MetaBase, + "meta": schema.MetaInfo, "state": "running" | "waiting" | "failed" | "completed", } ] @@ -175,7 +175,8 @@ class JobManager: 移除整理任务 """ with job_lock: - for mediaid, job in self._job_view.items(): + for mediaid in list(self._job_view): + job = self._job_view[mediaid] for task in job["tasks"]: if task["fileitem"].path == fileitem.path and task["fileitem"].storage == fileitem.storage: job["tasks"].remove(task) @@ -214,7 +215,7 @@ class JobManager: if __mediaid__ not in self._job_view: return False with job_lock: - return all([job["state"] == "completed" for job in self._job_view[__mediaid__]["tasks"]]) + return all([job["state"] in ["completed", "failed"] for job in self._job_view[__mediaid__]["tasks"]]) def count(self, media: MediaInfo, season: int = None) -> int: """ @@ -266,7 +267,7 @@ class TransferChain(ChainBase, metaclass=Singleton): _transfer_thread = None # 文件整理检查间隔(秒) - _transfer_interval = 600 if settings.DEV else 10 + _transfer_interval = 0 def __init__(self): super().__init__() @@ -420,7 +421,7 @@ class TransferChain(ChainBase, metaclass=Singleton): # 失败数量 fail_num = 0 - while not global_vars.is_system_stopped: + while not global_vars.is_system_stopped and self._transfer_interval: try: item: TransferQueue = self._queue.get(timeout=self._transfer_interval) if item: diff --git a/app/core/meta/metabase.py b/app/core/meta/metabase.py index 17870721..6939c8b1 100644 --- a/app/core/meta/metabase.py +++ b/app/core/meta/metabase.py @@ -589,9 +589,10 @@ class MetaBase(object): """ 转为字典 """ - dicts = asdict(self) + dicts = vars(self).copy() dicts["type"] = self.type.value if self.type else None dicts["season_episode"] = self.season_episode dicts["edition"] = self.edition dicts["name"] = self.name + dicts["episode_list"] = self.episode_list return dicts diff --git a/app/schemas/context.py b/app/schemas/context.py index faaabdd9..7ba78a7a 100644 --- a/app/schemas/context.py +++ b/app/schemas/context.py @@ -39,6 +39,8 @@ class MetaInfo(BaseModel): end_episode: Optional[int] = None # SxxExx season_episode: Optional[str] = None + # 集列表 + episode_list: Optional[List[int]] = Field(default_factory=list) # Partx Cd Dvd Disk Disc part: Optional[str] = None # 识别的资源类型