Verified Commit 06bcb034 authored by Patrick van der Leer's avatar Patrick van der Leer
Browse files

temp fix for blackhole crap

parent 54978156
Pipeline #293 passed with stage
in 5 minutes and 9 seconds
......@@ -114,27 +114,34 @@ def save_book_edition_file(base_path, filename, result):
def handle(base_path, full_path):
"""
:param base_path:
:param full_path:
:return: saved, new, book
:rtype: tuple(bool, bool, Book)
"""
from eBookHub.models import BookEditionFile
if BookEditionFile.is_known_files(full_path):
return True, BookEditionFile.lookup_by_checksum(full_path).first()
return False, False, BookEditionFile.lookup_by_checksum(full_path).first()
filename = full_path.replace(base_path, "", 1).lstrip("/")
resultset = process_file(filename)
if not resultset or len(resultset) < 0:
# enter as no f'ing clue
return False, None
return False, False, None
if len(resultset) == 1:
return True, save_book_edition_file(base_path, filename, resultset[0])
return True, True, save_book_edition_file(base_path, filename, resultset[0])
return True, save_book_edition_file(base_path, filename, resultset)
return True, True, save_book_edition_file(base_path, filename, resultset)
def process_blackhole(blackhole_path):
for file in glob.iglob('{}/*'.format(blackhole_path), recursive=True):
saved, book_edition_file = handle(blackhole_path, file)
if saved:
saved, new, book_edition_file = handle(blackhole_path, file)
if saved and new:
from eBookHub.models import BookEditionFile
assert isinstance(book_edition_file, BookEditionFile)
if book_edition_file.book_edition is None:
......
......@@ -14,10 +14,4 @@ def blackhole(path=None): # pragma: no cover
path = app.config['BLACKHOLE_PATH']
for saved, book_edition_file, filename in process_blackhole(path):
cleaned_fn = filename.replace(path, "", 1).lstrip("/")
if saved:
if book_edition_file.book_edition is None:
print("TEMP SAVED: {}".format(cleaned_fn))
else:
print("SAVED: {}".format(cleaned_fn))
else:
print("No clue what this is: {}".format(cleaned_fn))
print("Processed {}".format(cleaned_fn))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment