fix directories

This commit is contained in:
jxxghp
2024-07-02 17:47:29 +08:00
parent f23be671c0
commit 1822d01d17
17 changed files with 176 additions and 239 deletions
+7 -6
View File
@@ -245,22 +245,23 @@ class DownloadChain(ChainBase):
# 下载目录
if save_path:
# 有自定义下载目录时,尝试匹配目录配置
dir_info = self.directoryhelper.get_download_dir(_media, to_path=Path(save_path))
dir_info = self.directoryhelper.get_dir(_media, src_path=Path(save_path), local=True)
else:
# 根据媒体信息查询下载目录配置
dir_info = self.directoryhelper.get_download_dir(_media)
dir_info = self.directoryhelper.get_dir(_media, local=True)
# 拼装子目录
if dir_info:
# 一级目录
if not dir_info.media_type and dir_info.auto_category:
if not dir_info.media_type and dir_info.download_type_folder:
# 一级自动分类
download_dir = Path(dir_info.path) / _media.type.value
download_dir = Path(dir_info.download_path) / _media.type.value
else:
# 一级不分类
download_dir = Path(dir_info.path)
download_dir = Path(dir_info.download_path)
# 二级目录
if not dir_info.category and dir_info.auto_category and _media and _media.category:
if not dir_info.media_category and dir_info.download_category_folder and _media and _media.category:
# 二级自动分类
download_dir = download_dir / _media.category
elif save_path:
-1
View File
@@ -5,7 +5,6 @@ from cachetools import cached, TTLCache
from app import schemas
from app.chain import ChainBase
from app.core.config import settings
from app.core.context import MediaInfo
from app.schemas import MediaType
from app.utils.singleton import Singleton
+3 -3
View File
@@ -63,11 +63,11 @@ class TransferChain(ChainBase):
# 全局锁,避免重复处理
with lock:
logger.info("开始执行下载器文件转移 ...")
logger.info("开始整理下载器中已经完成下载的文件 ...")
# 从下载器获取种子列表
torrents: Optional[List[TransferTorrent]] = self.list_torrents(status=TorrentStatus.TRANSFER)
if not torrents:
logger.info("没有获取到已完成下载任务")
logger.info("没有已完成下载但未整理的任务")
return False
logger.info(f"获取到 {len(torrents)} 个已完成的下载任务")
@@ -109,7 +109,7 @@ class TransferChain(ChainBase):
# 设置下载任务状态
self.transfer_completed(hashs=torrent.hash, path=torrent.path)
# 结束
logger.info("下载器文件转移执行完成")
logger.info("所有下载器中下载完成的文件已整理完成")
return True
def __do_transfer(self, fileitem: FileItem,