From 3f60cb3f7d2a2d19ad01a3ce7b362c2e8a52565e Mon Sep 17 00:00:00 2001 From: Attente <19653207+wikrin@users.noreply.github.com> Date: Thu, 26 Dec 2024 09:00:04 +0800 Subject: [PATCH] fix(storage): delete `Blu-ray` directory when removing movie file - Add logic to delete `BDMV` and `CERTIFICATE` directories when a movie file is removed - This ensures that empty Blu-ray folders are also cleaned up during the deletion process --- app/chain/storage.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/chain/storage.py b/app/chain/storage.py index 7b21bf4f..b2d3171e 100644 --- a/app/chain/storage.py +++ b/app/chain/storage.py @@ -131,6 +131,12 @@ class StorageChain(ChainBase): return False if fileitem.type == "dir": # 本身是目录 + if _blue_dir := self.list_files(fileitem=fileitem, recursion=False): + # 删除蓝光目录 + for _f in _blue_dir: + if _f.type == "dir" and _f.name in ["BDMV", "CERTIFICATE"]: + logger.warn(f"【{fileitem.storage}】{_f.path} 删除蓝光目录") + self.delete_file(_f) if self.any_files(fileitem, extensions=media_exts) is False: logger.warn(f"【{fileitem.storage}】{fileitem.path} 不存在其它媒体文件,删除空目录") return self.delete_file(fileitem)