Fixes some bugs with the indexer
This commit is contained in:
@@ -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
|
||||||
@@ -100,7 +102,7 @@ def __main__():
|
|||||||
threads = []
|
threads = []
|
||||||
comics = []
|
comics = []
|
||||||
thread_limit = threading.BoundedSemaphore(value=args.threads)
|
thread_limit = threading.BoundedSemaphore(value=args.threads)
|
||||||
|
|
||||||
for url in args.url:
|
for url in args.url:
|
||||||
comic_type = find_comic_class(url.netloc + url.path)
|
comic_type = find_comic_class(url.netloc + url.path)
|
||||||
comic = comic_type.create_from_url(url)
|
comic = comic_type.create_from_url(url)
|
||||||
@@ -121,16 +123,18 @@ 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__":
|
||||||
__main__()
|
__main__()
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user