feat:硬链接转复制时发系统通知提醒

This commit is contained in:
jxxghp 2024-05-27 08:11:44 +08:00
parent ca5a240fc4
commit 58acc62e16

View File

@ -18,6 +18,7 @@ from app.db.systemconfig_oper import SystemConfigOper
from app.db.transferhistory_oper import TransferHistoryOper from app.db.transferhistory_oper import TransferHistoryOper
from app.helper.directory import DirectoryHelper from app.helper.directory import DirectoryHelper
from app.helper.format import FormatParser from app.helper.format import FormatParser
from app.helper.message import MessageHelper
from app.helper.progress import ProgressHelper from app.helper.progress import ProgressHelper
from app.log import logger from app.log import logger
from app.schemas import TransferInfo, TransferTorrent, Notification, EpisodeFormat from app.schemas import TransferInfo, TransferTorrent, Notification, EpisodeFormat
@ -43,6 +44,7 @@ class TransferChain(ChainBase):
self.tmdbchain = TmdbChain() self.tmdbchain = TmdbChain()
self.systemconfig = SystemConfigOper() self.systemconfig = SystemConfigOper()
self.directoryhelper = DirectoryHelper() self.directoryhelper = DirectoryHelper()
self.messagehelper = MessageHelper()
def process(self) -> bool: def process(self) -> bool:
""" """
@ -352,10 +354,20 @@ class TransferChain(ChainBase):
transfers[mkey].file_list_new.extend(transferinfo.file_list_new) transfers[mkey].file_list_new.extend(transferinfo.file_list_new)
transfers[mkey].fail_list.extend(transferinfo.fail_list) transfers[mkey].fail_list.extend(transferinfo.fail_list)
# 硬链接检查
temp_transfer_type = transfer_type
if transfer_type == "link":
if not SystemUtils.is_same_disk(file_path, transferinfo.target_path):
logger.warn(f"{file_path}{transferinfo.target_path} 不在同一磁盘/存储空间/映射目录,未能硬链接,请检查存储空间占用和整理耗时,确认是否为复制")
self.messagehelper.put(f"{file_path}{transferinfo.target_path} 不在同一磁盘/存储空间/映射目录,疑似硬链接失败,请检查是否为复制",
title="硬链接失败",
role="system")
temp_transfer_type = "copy"
# 新增转移成功历史记录 # 新增转移成功历史记录
self.transferhis.add_success( self.transferhis.add_success(
src_path=file_path, src_path=file_path,
mode=transfer_type, mode=temp_transfer_type,
download_hash=download_hash, download_hash=download_hash,
meta=file_meta, meta=file_meta,
mediainfo=file_mediainfo, mediainfo=file_mediainfo,
@ -365,7 +377,7 @@ class TransferChain(ChainBase):
if transferinfo.need_scrape: if transferinfo.need_scrape:
self.scrape_metadata(path=transferinfo.target_path, self.scrape_metadata(path=transferinfo.target_path,
mediainfo=file_mediainfo, mediainfo=file_mediainfo,
transfer_type=transfer_type, transfer_type=temp_transfer_type,
metainfo=file_meta) metainfo=file_meta)
# 更新进度 # 更新进度
processed_num += 1 processed_num += 1