Fixes some bugs with the indexer

This commit is contained in:
2025-08-12 18:50:00 -06:00
parent e1a72a6f1a
commit fd9a7bb4e9
2 changed files with 13 additions and 9 deletions

View File

@@ -17,6 +17,8 @@
import logging import logging
import logging.handlers import logging.handlers
import argparse import argparse
from signal import signal, SIGINT
from sys import exit
import datetime import datetime
import threading import threading
import time import time
@@ -121,15 +123,17 @@ def __main__():
if not comic_download.is_strip_present(comic, base_path, ".cbz", str(index)): if not comic_download.is_strip_present(comic, base_path, ".cbz", str(index)):
t = threading.Thread(name=str(comic.get_identifier_string()) + "-" + str(index), target=load_strip, args=(base_path, comic, index, args.plain, thread_limit)) t = threading.Thread(name=str(comic.get_identifier_string()) + "-" + str(index), target=load_strip, args=(base_path, comic, index, args.plain, thread_limit))
threads.append(t) threads.append(t)
t.daemon = True
t.start() t.start()
finally: finally:
logging.info("Saving index")
comic_download.save_index(base_path) comic_download.save_index(base_path)
try: try:
for t in threads: while any([t.is_alive() for t in threads]):
t.join() time.sleep(1)
finally: finally:
for comic in comics: logging.info("Saving index")
comic_download.save_index(base_path) comic_download.save_index(base_path)
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -158,9 +158,9 @@ def index_strip(strip):
global _index_loaded global _index_loaded
global _index_lock global _index_lock
with _index_lock: with _index_lock:
if not strip.comic.identifier in strip_index: if not strip.comic.get_identifier_string() in strip_index:
strip_index[strip.comic.get_identifier_string()] = {} strip_index[strip.comic.get_identifier_string()] = {}
strip_index[strip.comic.get_identifier_string()][strip.identifier] = strip.get_filename() strip_index[strip.comic.get_identifier_string()][strip.get_identifier_string()] = strip.get_filename()
def is_strip_present(comic, base_path: Path, suffix: str, identifier) -> bool: def is_strip_present(comic, base_path: Path, suffix: str, identifier) -> bool:
""" """
@@ -177,9 +177,9 @@ def is_strip_present(comic, base_path: Path, suffix: str, identifier) -> bool:
global _index_lock global _index_lock
if not comic.get_identifier_string() in strip_index: if not comic.get_identifier_string() in strip_index:
return False return False
if not identifier in strip_index[comic.get_identifier_string()]: if not get_identifier_string(identifier) in strip_index[comic.get_identifier_string()]:
return False return False
path = Path(base_path, strip_index[comic.get_identifier_string()][identifier] + suffix) path = Path(base_path, strip_index[comic.get_identifier_string()][get_identifier_string(identifier)] + suffix)
return path.exists() return path.exists()