mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-13 08:24:40 +08:00
GUI: Optimize restore prettify to only run on screen update
This commit is contained in:
parent
fc8e2f1409
commit
d0d4f3ca4d
1 changed files with 6 additions and 4 deletions
|
@ -310,10 +310,7 @@ def gui_thread_runner(
|
|||
else:
|
||||
if __fn_name == "restore":
|
||||
# We only need last line since restore outputs self contained json status lines
|
||||
try:
|
||||
stdout_cache = json.dumps(json.loads(stdout_data), indent=4)
|
||||
except json.JSONDecodeError:
|
||||
stdout_cache = stdout_data
|
||||
stdout_cache = stdout_data
|
||||
else:
|
||||
stdout_cache += stdout_data.strip("\r\n") + "\n"
|
||||
# So the FreeSimpleGUI update implementation is **really** slow to update multiline when autoscroll=True
|
||||
|
@ -350,6 +347,11 @@ def gui_thread_runner(
|
|||
if time.monotonic() - start_time > 1:
|
||||
if len(stdout_cache) > 1000:
|
||||
stdout_cache = stdout_cache[-1000:]
|
||||
if __fn_name == "restore":
|
||||
try:
|
||||
stdout_cache = json.dumps(json.loads(stdout_cache), indent=4)
|
||||
except json.JSONDecodeError as exc:
|
||||
pass
|
||||
# Don't update GUI if there isn't anything to update so it will avoid scrolling back to top every second
|
||||
if (
|
||||
previous_stdout_cache != stdout_cache
|
||||
|
|
Loading…
Add table
Reference in a new issue