fix: reset state when starting new source run
This commit is contained in:
@@ -71,6 +71,7 @@ def main():
|
|||||||
|
|
||||||
if args.mode == "source":
|
if args.mode == "source":
|
||||||
from source.source import run_source_mode
|
from source.source import run_source_mode
|
||||||
|
state.reset_state(mode="source")
|
||||||
try:
|
try:
|
||||||
run_source_mode()
|
run_source_mode()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|||||||
@@ -127,6 +127,24 @@ def clear_error():
|
|||||||
save_state(state)
|
save_state(state)
|
||||||
|
|
||||||
|
|
||||||
|
def reset_state(mode=None):
|
||||||
|
"""Сбрасывает состояние для нового запуска (source, target или полностью)."""
|
||||||
|
global _LAST_STATE
|
||||||
|
# Загружаем текущее, чтобы не потерять пути к архивам если пользователь хочет
|
||||||
|
# Но completed_steps и stage сбрасываем
|
||||||
|
state = load_state()
|
||||||
|
state["stage"] = "INIT"
|
||||||
|
state["mode"] = mode
|
||||||
|
state["completed_steps"] = []
|
||||||
|
state["interrupted_at"] = None
|
||||||
|
state["resumable_hint"] = None
|
||||||
|
state["last_error"] = None
|
||||||
|
state["paused"] = False
|
||||||
|
state["updated_at"] = datetime.now().isoformat()
|
||||||
|
_LAST_STATE = state
|
||||||
|
save_state(state)
|
||||||
|
|
||||||
|
|
||||||
def set_interrupted():
|
def set_interrupted():
|
||||||
"""Помечает, что скрипт был прерван (Ctrl+C, SIGTERM)."""
|
"""Помечает, что скрипт был прерван (Ctrl+C, SIGTERM)."""
|
||||||
state = load_state()
|
state = load_state()
|
||||||
|
|||||||
Reference in New Issue
Block a user