mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-06-28 03:02:34 +08:00
fix transfer
This commit is contained in:
@@ -101,9 +101,7 @@ class TransferChain(ChainBase):
|
||||
transfer_dirinfo = dir_info
|
||||
break
|
||||
if not transfer_dirinfo:
|
||||
logger.info(f"文件 {file_path} 不在下载器监控目录中,不通过下载器进行整理")
|
||||
# 设置下载任务状态
|
||||
self.transfer_completed(hashs=torrent.hash, path=file_path)
|
||||
logger.debug(f"文件 {file_path} 不在下载器监控目录中,不通过下载器进行整理")
|
||||
continue
|
||||
# 查询下载记录识别情况
|
||||
downloadhis: DownloadHistory = self.downloadhis.get_by_hash(torrent.hash)
|
||||
@@ -134,7 +132,9 @@ class TransferChain(ChainBase):
|
||||
size=file_path.stat().st_size,
|
||||
extension=file_path.suffix.lstrip('.'),
|
||||
),
|
||||
mediainfo=mediainfo, download_hash=torrent.hash
|
||||
target_storage=transfer_dirinfo.library_storage,
|
||||
mediainfo=mediainfo,
|
||||
download_hash=torrent.hash
|
||||
)
|
||||
|
||||
# 设置下载任务状态
|
||||
|
||||
@@ -158,8 +158,8 @@ class TransferHistoryOper(DbOper):
|
||||
src=fileitem.path,
|
||||
src_storage=fileitem.storage,
|
||||
src_fileitem=json.dumps(fileitem.dict()),
|
||||
dest=transferinfo.target_item.path,
|
||||
dest_storage=transferinfo.target_item.storage,
|
||||
dest=transferinfo.target_item.path if transferinfo.target_item else None,
|
||||
dest_storage=transferinfo.target_item.storage if transferinfo.target_item else None,
|
||||
dest_fileitem=json.dumps(transferinfo.target_item.dict()),
|
||||
mode=mode,
|
||||
type=mediainfo.type.value,
|
||||
|
||||
@@ -271,6 +271,11 @@ class FileManagerModule(_ModuleBase):
|
||||
:param scrape: 是否刮削元数据
|
||||
:return: {path, target_path, message}
|
||||
"""
|
||||
# 检查目录路径
|
||||
if fileitem.storage == "local" and not Path(fileitem.path).exists():
|
||||
return TransferInfo(success=False,
|
||||
fileitem=fileitem,
|
||||
message=f"{fileitem.path} 不存在")
|
||||
# 目标路径不能是文件
|
||||
if target_path and target_path.is_file():
|
||||
logger.error(f"整理目标路径 {target_path} 是一个文件")
|
||||
@@ -284,6 +289,9 @@ class FileManagerModule(_ModuleBase):
|
||||
else:
|
||||
dir_info = directoryhelper.get_dir(mediainfo)
|
||||
if dir_info:
|
||||
# 目标存储类型
|
||||
if not target_storage:
|
||||
target_storage = dir_info.library_storage
|
||||
# 是否需要刮削
|
||||
if scrape is None:
|
||||
need_scrape = dir_info.scraping
|
||||
@@ -661,7 +669,7 @@ class FileManagerModule(_ModuleBase):
|
||||
# 获取目标目录
|
||||
target_oper: StorageBase = self.__get_storage_oper(target_storage)
|
||||
if not target_oper:
|
||||
logger.error(f"不支持 {target_storage} 的文件整理")
|
||||
logger.error(f"不支持到 {target_storage} 的文件整理")
|
||||
return None, f"不支持的文件存储:{target_storage}"
|
||||
|
||||
logger.info(f"正在{transfer_type}目录:{fileitem.path} 到 {target_path}")
|
||||
@@ -815,18 +823,6 @@ class FileManagerModule(_ModuleBase):
|
||||
modify_time=_path.stat().st_mtime
|
||||
)
|
||||
|
||||
# 检查目录路径
|
||||
if fileitem.storage == "local" and not Path(fileitem.path).exists():
|
||||
return TransferInfo(success=False,
|
||||
fileitem=fileitem,
|
||||
message=f"{fileitem.path} 不存在")
|
||||
|
||||
if target_storage == "local":
|
||||
# 检查目标路径
|
||||
if not target_path.exists():
|
||||
logger.info(f"目标路径不存在,正在创建:{target_path} ...")
|
||||
target_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 重命名格式
|
||||
rename_format = settings.TV_RENAME_FORMAT \
|
||||
if mediainfo.type == MediaType.TV else settings.MOVIE_RENAME_FORMAT
|
||||
|
||||
@@ -247,7 +247,7 @@ class U115Pan(StorageBase, metaclass=Singleton):
|
||||
return sub_file
|
||||
return None
|
||||
|
||||
# 逐级查找和创建目录
|
||||
# 逐级查找
|
||||
fileitem = schemas.FileItem(fileid="0")
|
||||
for part in path.parts:
|
||||
if part == "/":
|
||||
|
||||
Reference in New Issue
Block a user