mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix bug
This commit is contained in:
@@ -603,7 +603,7 @@ class TransferChain(ChainBase, metaclass=Singleton):
|
|||||||
finished_files.append(Path(fileitem.path).as_posix())
|
finished_files.append(Path(fileitem.path).as_posix())
|
||||||
__process_msg = f"{fileitem.name} 整理完成"
|
__process_msg = f"{fileitem.name} 整理完成"
|
||||||
logger.info(__process_msg)
|
logger.info(__process_msg)
|
||||||
progress.update(value=processed_num / total_num * 100,
|
progress.update(value=(processed_num / total_num) * 100,
|
||||||
text=__process_msg,
|
text=__process_msg,
|
||||||
data={})
|
data={})
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
|
|||||||
+30
-10
@@ -15,9 +15,12 @@ class ProgressHelper(metaclass=WeakSingleton):
|
|||||||
if isinstance(key, Enum):
|
if isinstance(key, Enum):
|
||||||
key = key.value
|
key = key.value
|
||||||
self._key = key
|
self._key = key
|
||||||
self._progress = TTLCache(maxsize=1024, ttl=24 * 60 * 60)
|
self._progress = TTLCache(region="progress", maxsize=1024, ttl=24 * 60 * 60)
|
||||||
|
|
||||||
def __reset(self):
|
def __reset(self):
|
||||||
|
"""
|
||||||
|
重置进度
|
||||||
|
"""
|
||||||
self._progress[self._key] = {
|
self._progress[self._key] = {
|
||||||
"enable": False,
|
"enable": False,
|
||||||
"value": 0,
|
"value": 0,
|
||||||
@@ -26,31 +29,48 @@ class ProgressHelper(metaclass=WeakSingleton):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
"""
|
||||||
|
开始进度
|
||||||
|
"""
|
||||||
self.__reset()
|
self.__reset()
|
||||||
self._progress[self._key]['enable'] = True
|
current = self._progress.get(self._key)
|
||||||
|
if not current:
|
||||||
|
return
|
||||||
|
current['enable'] = True
|
||||||
|
self._progress[self._key] = current
|
||||||
|
|
||||||
def end(self):
|
def end(self):
|
||||||
if not self._progress.get(self._key):
|
"""
|
||||||
|
结束进度
|
||||||
|
"""
|
||||||
|
current = self._progress.get(self._key)
|
||||||
|
if not current:
|
||||||
return
|
return
|
||||||
self._progress[self._key].update(
|
current.update(
|
||||||
{
|
{
|
||||||
"enable": False,
|
"enable": False,
|
||||||
"value": 100,
|
"value": 100,
|
||||||
"text": ""
|
"text": ""
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
self._progress[self._key] = current
|
||||||
|
|
||||||
def update(self, value: Union[float, int] = None, text: Optional[str] = None, data: dict = None):
|
def update(self, value: Union[float, int] = None, text: Optional[str] = None, data: dict = None):
|
||||||
if not self._progress.get(self._key).get('enable'):
|
"""
|
||||||
|
更新进度
|
||||||
|
"""
|
||||||
|
current = self._progress.get(self._key)
|
||||||
|
if not current or not current.get('enable'):
|
||||||
return
|
return
|
||||||
if value:
|
if value:
|
||||||
self._progress[self._key]['value'] = value
|
current['value'] = value
|
||||||
if text:
|
if text:
|
||||||
self._progress[self._key]['text'] = text
|
current['text'] = text
|
||||||
if data:
|
if data:
|
||||||
if not self._progress[self._key].get('data'):
|
if not current.get('data'):
|
||||||
self._progress[self._key]['data'] = {}
|
current['data'] = {}
|
||||||
self._progress[self._key]['data'].update(data)
|
current['data'].update(data)
|
||||||
|
self._progress[self._key] = current
|
||||||
|
|
||||||
def get(self) -> dict:
|
def get(self) -> dict:
|
||||||
return self._progress.get(self._key)
|
return self._progress.get(self._key)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ def transfer_process(path: str) -> Callable[[int | float], None]:
|
|||||||
"""
|
"""
|
||||||
传输进度回调
|
传输进度回调
|
||||||
"""
|
"""
|
||||||
pbar = tqdm(total=100, desc="整理进度")
|
pbar = tqdm(total=100, desc="整理进度", unit="%")
|
||||||
progress = ProgressHelper(path)
|
progress = ProgressHelper(path)
|
||||||
progress.start()
|
progress.start()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user