diff options
Diffstat (limited to 'src/book_store.py')
| -rw-r--r-- | src/book_store.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/book_store.py b/src/book_store.py index 1bc296f..687f01b 100644 --- a/src/book_store.py +++ b/src/book_store.py @@ -11,7 +11,7 @@ import src.book_files as book_files logger = logging.getLogger(__name__) -def store(library, conn, data, cover, books, book, remove_book_sources): +def store(library, conn, data, cover, books, book): book_id = book['id'] if book else nanoid.generate() directory = f'{library}/{book_id}' @@ -22,9 +22,9 @@ def store(library, conn, data, cover, books, book, remove_book_sources): if book: if not already_exist(directory, books) or has_delete(library, book_id, books): - update_books(directory, books, remove_book_sources) + update_books(directory, books) else: - update_books(directory, books, remove_book_sources) + update_books(directory, books) if book: db.update_book(conn, book_id, data) @@ -56,7 +56,7 @@ def has_delete(library, book_id, books): return True return False -def update_books(directory, books, remove_book_sources): +def update_books(directory, books): try: tmp_dir = f'{directory}/tmp' os.makedirs(tmp_dir, exist_ok=True) @@ -79,12 +79,6 @@ def update_books(directory, books, remove_book_sources): dest = f'{directory}/{name}{ext}' logger.info('Copying %s to %s', src, dest) shutil.copyfile(src, dest) - # Remove sources outside of book dir - if remove_book_sources: - for path in books.keys(): - if os.path.dirname(path) != directory: - logger.info('Removing source: %s', path) - pathlib.Path.unlink(path) finally: # Remove tmp shutil.rmtree(f'{directory}/tmp', ignore_errors=True) |
