mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-02-02 18:22:39 +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())
|
||||
__process_msg = f"{fileitem.name} 整理完成"
|
||||
logger.info(__process_msg)
|
||||
progress.update(value=processed_num / total_num * 100,
|
||||
progress.update(value=(processed_num / total_num) * 100,
|
||||
text=__process_msg,
|
||||
data={})
|
||||
except queue.Empty:
|
||||
|
||||
@@ -15,9 +15,12 @@ class ProgressHelper(metaclass=WeakSingleton):
|
||||
if isinstance(key, Enum):
|
||||
key = key.value
|
||||
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):
|
||||
"""
|
||||
重置进度
|
||||
"""
|
||||
self._progress[self._key] = {
|
||||
"enable": False,
|
||||
"value": 0,
|
||||
@@ -26,31 +29,48 @@ class ProgressHelper(metaclass=WeakSingleton):
|
||||
}
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
开始进度
|
||||
"""
|
||||
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):
|
||||
if not self._progress.get(self._key):
|
||||
"""
|
||||
结束进度
|
||||
"""
|
||||
current = self._progress.get(self._key)
|
||||
if not current:
|
||||
return
|
||||
self._progress[self._key].update(
|
||||
current.update(
|
||||
{
|
||||
"enable": False,
|
||||
"value": 100,
|
||||
"text": ""
|
||||
}
|
||||
)
|
||||
self._progress[self._key] = current
|
||||
|
||||
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
|
||||
if value:
|
||||
self._progress[self._key]['value'] = value
|
||||
current['value'] = value
|
||||
if text:
|
||||
self._progress[self._key]['text'] = text
|
||||
current['text'] = text
|
||||
if data:
|
||||
if not self._progress[self._key].get('data'):
|
||||
self._progress[self._key]['data'] = {}
|
||||
self._progress[self._key]['data'].update(data)
|
||||
if not current.get('data'):
|
||||
current['data'] = {}
|
||||
current['data'].update(data)
|
||||
self._progress[self._key] = current
|
||||
|
||||
def get(self) -> dict:
|
||||
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.start()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user