mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 17:08:35 +08:00
fix:去除文件操作全局锁
This commit is contained in:
@@ -580,6 +580,11 @@ class TransferChain(ChainBase, metaclass=Singleton):
|
|||||||
fileitem = task.fileitem
|
fileitem = task.fileitem
|
||||||
|
|
||||||
with task_lock:
|
with task_lock:
|
||||||
|
# 获取当前最新总数
|
||||||
|
current_total = self.jobview.total()
|
||||||
|
# 更新总数,取当前总数和当前已处理+运行中+队列中的最大值
|
||||||
|
self._total_num = max(self._total_num, current_total)
|
||||||
|
|
||||||
# 如果当前没有在运行的任务且处理数为0,说明是一个新序列的开始
|
# 如果当前没有在运行的任务且处理数为0,说明是一个新序列的开始
|
||||||
if self._active_tasks == 0 and self._processed_num == 0:
|
if self._active_tasks == 0 and self._processed_num == 0:
|
||||||
logger.info("开始整理队列处理...")
|
logger.info("开始整理队列处理...")
|
||||||
@@ -588,7 +593,6 @@ class TransferChain(ChainBase, metaclass=Singleton):
|
|||||||
# 重置计数
|
# 重置计数
|
||||||
self._processed_num = 0
|
self._processed_num = 0
|
||||||
self._fail_num = 0
|
self._fail_num = 0
|
||||||
self._total_num = self.jobview.total()
|
|
||||||
__process_msg = f"开始整理队列处理,当前共 {self._total_num} 个文件 ..."
|
__process_msg = f"开始整理队列处理,当前共 {self._total_num} 个文件 ..."
|
||||||
logger.info(__process_msg)
|
logger.info(__process_msg)
|
||||||
self._progress.update(value=0,
|
self._progress.update(value=0,
|
||||||
@@ -605,6 +609,7 @@ class TransferChain(ChainBase, metaclass=Singleton):
|
|||||||
text=__process_msg)
|
text=__process_msg)
|
||||||
# 整理
|
# 整理
|
||||||
state, err_msg = self.__handle_transfer(task=task, callback=item.callback)
|
state, err_msg = self.__handle_transfer(task=task, callback=item.callback)
|
||||||
|
|
||||||
with task_lock:
|
with task_lock:
|
||||||
if not state:
|
if not state:
|
||||||
# 任务失败
|
# 任务失败
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class LocalStorage(StorageBase):
|
|||||||
return None
|
return None
|
||||||
path_obj = Path(fileitem.path) / name
|
path_obj = Path(fileitem.path) / name
|
||||||
if not path_obj.exists():
|
if not path_obj.exists():
|
||||||
path_obj.mkdir(parents=True)
|
path_obj.mkdir(parents=True, exist_ok=True)
|
||||||
return self.__get_diritem(path_obj)
|
return self.__get_diritem(path_obj)
|
||||||
|
|
||||||
def get_folder(self, path: Path) -> Optional[schemas.FileItem]:
|
def get_folder(self, path: Path) -> Optional[schemas.FileItem]:
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class Rclone(StorageBase):
|
|||||||
logger.info(f"【rclone】配置写入文件:{filepath}")
|
logger.info(f"【rclone】配置写入文件:{filepath}")
|
||||||
path = Path(filepath)
|
path = Path(filepath)
|
||||||
if not path.parent.exists():
|
if not path.parent.exists():
|
||||||
path.parent.mkdir(parents=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
path.write_text(conf.get('content'), encoding='utf-8')
|
path.write_text(conf.get('content'), encoding='utf-8')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ from app.schemas import TransferInfo, TmdbEpisode, TransferDirectoryConf, FileIt
|
|||||||
from app.schemas.types import MediaType, ChainEventType
|
from app.schemas.types import MediaType, ChainEventType
|
||||||
from app.utils.system import SystemUtils
|
from app.utils.system import SystemUtils
|
||||||
|
|
||||||
lock = Lock()
|
|
||||||
|
|
||||||
|
|
||||||
class TransHandler:
|
class TransHandler:
|
||||||
"""
|
"""
|
||||||
@@ -383,12 +381,10 @@ class TransHandler:
|
|||||||
and fileitem.storage != "local" and target_storage != "local"):
|
and fileitem.storage != "local" and target_storage != "local"):
|
||||||
return None, f"不支持 {fileitem.storage} 到 {target_storage} 的文件整理"
|
return None, f"不支持 {fileitem.storage} 到 {target_storage} 的文件整理"
|
||||||
|
|
||||||
# 加锁
|
|
||||||
with lock:
|
|
||||||
if fileitem.storage == "local" and target_storage == "local":
|
if fileitem.storage == "local" and target_storage == "local":
|
||||||
# 创建目录
|
# 创建目录
|
||||||
if not target_file.parent.exists():
|
if not target_file.parent.exists():
|
||||||
target_file.parent.mkdir(parents=True)
|
target_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
# 本地到本地
|
# 本地到本地
|
||||||
if transfer_type == "copy":
|
if transfer_type == "copy":
|
||||||
state = source_oper.copy(fileitem, target_file.parent, target_file.name)
|
state = source_oper.copy(fileitem, target_file.parent, target_file.name)
|
||||||
@@ -449,7 +445,7 @@ class TransHandler:
|
|||||||
if tmp_file:
|
if tmp_file:
|
||||||
# 创建目录
|
# 创建目录
|
||||||
if not target_file.parent.exists():
|
if not target_file.parent.exists():
|
||||||
target_file.parent.mkdir(parents=True)
|
target_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
# 将tmp_file移动后target_file
|
# 将tmp_file移动后target_file
|
||||||
SystemUtils.move(tmp_file, target_file)
|
SystemUtils.move(tmp_file, target_file)
|
||||||
if transfer_type == "move":
|
if transfer_type == "move":
|
||||||
|
|||||||
Reference in New Issue
Block a user