fix(state): make add_file_to_state idempotent
This commit is contained in:
@@ -27,9 +27,6 @@ INTERVAL = 10
|
||||
SENTINEL_FILE = os.path.expanduser("~/.config/obs-studio/.sentinel")
|
||||
OBS_MAX_RETRIES = 10
|
||||
|
||||
seen_files = set()
|
||||
seen_lock = Lock()
|
||||
|
||||
def shutdown(signum, frame):
|
||||
global running
|
||||
logger.info(f"Received signal {signum}, shutting down cleanly")
|
||||
@@ -120,11 +117,6 @@ class Handler(FileSystemEventHandler):
|
||||
if not event.src_path.endswith(".ts"):
|
||||
return
|
||||
|
||||
with seen_lock:
|
||||
if event.src_path in seen_files:
|
||||
return
|
||||
seen_files.add(event.src_path)
|
||||
|
||||
add_file_to_state(event.src_path)
|
||||
logger.info(f"Added new file to state: {event.src_path}")
|
||||
|
||||
|
||||
@@ -33,6 +33,11 @@ def add_file_to_state(file_path: str) -> None:
|
||||
state = load_state()
|
||||
files = state.get("files", [])
|
||||
|
||||
# Idempotency guard
|
||||
existing_paths = {f["path"] for f in files}
|
||||
if file_path in existing_paths:
|
||||
return
|
||||
|
||||
files.append({
|
||||
"path": file_path,
|
||||
"timestamp": datetime.datetime.now().timestamp(),
|
||||
|
||||
Reference in New Issue
Block a user