Skip to content

Very weird bug when adding a book (maybe a regression between now and Mar 2021) #3357

Open
@Dinth

Description

@Dinth

Describe the bug/problem

Im trying to add a book i have purchased - it gets added but without any metadata. If i want to add metadata, ive got an error when saving, which is saying that epub of another book of the same author doesnt exist on the drive.

To Reproduce

Steps to reproduce the behavior:

  1. I have uploaded a book

Image

  1. I can save it like that all right:

Image

  1. But if i fetch metadata for that book:

Image

  1. Im no longer able to save it:

Image

  1. The book in the error message is a completely different book ive got in the library:

Image

  1. And calibre-web indeed cannot download its epub (nor mobi...):

Image

  1. Whats very weird, because files are definetely there, have the correct permissions and clearly Calibre-web was able to access it in 2021 (generated kepub):

Image

  1. Now i can see that Calibre-Web has created a new folder for Wróg here, but its empty...

Image

  1. and instead, it has actually uploaded the newly added book here:

Image

Logfile


2025-04-08 11:27:48,944] DEBUG {cps.updater:331} Stable version: 0.6.24
[2025-04-08 11:27:56,113] DEBUG {cps.uploader:275} Temporary file: /tmp/calibre_web/2d6d7e17d3f865bf5dc851155a591a37
[2025-04-08 11:27:56,235]  WARN {py.warnings:110} /app/calibre-web/cps/editbooks.py:1405: SAWarning: Object of type <Books> not in session, add operation along 'Authors.books' won't proceed (This warning originated from the Session 'autoflush' process, which was invoked automatically in response to a user-initiated operation. Consider using ``no_autoflush`` context manager if this warning happended while initializing objects.)
  db_element = db_session.query(db_object).filter((func.lower(db_filter).ilike(add_element))).all()
[2025-04-08 11:27:56,239]  WARN {py.warnings:110} /app/calibre-web/cps/editbooks.py:1405: SAWarning: Object of type <Books> not in session, add operation along 'Languages.books' won't proceed (This warning originated from the Session 'autoflush' process, which was invoked automatically in response to a user-initiated operation. Consider using ``no_autoflush`` context manager if this warning happended while initializing objects.)
  db_element = db_session.query(db_object).filter((func.lower(db_filter).ilike(add_element))).all()
[2025-04-08 11:27:56,364] DEBUG {cps.helper:536} Moving title: /tmp/calibre_web/2d6d7e17d3f865bf5dc851155a591a37 to /books/!Calibre/Łukasz Orbitowski/Wróg (1508)
[2025-04-08 11:27:56,428] DEBUG {cps.services.worker:91} Add Task for user: admin - Upload Wróg
[2025-04-08 11:28:00,826] DEBUG {cps.services.worker:91} Add Task for user: admin - Upload Wróg
[2025-04-08 11:28:14,873] ERROR {cps.editbooks:579} [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wróg (1508)/Wróg - Łukasz Orbitowski.epub'
Traceback (most recent call last):
  File "/usr/lib/python3.12/shutil.py", line 886, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wróg (1508)/Wróg - Łukasz Orbitowski.epub' -> '/books/!Calibre/Lukasz Orbitowski/Wróg (1508)/Wróg - Lukasz Orbitowski.epub'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/calibre-web/cps/editbooks.py", line 464, in do_edit_book
    input_authors, author_change = handle_author_on_edit(book, to_save["authors"])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 1325, in handle_author_on_edit
    input_authors = prepare_authors(author_name, config.get_book_path(), config.config_use_google_drive)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 666, in prepare_authors
    helper.rename_all_files_on_change(one_book, new_path, new_path, all_new_name, gdrive)
  File "/app/calibre-web/cps/helper.py", line 401, in rename_all_files_on_change
    shutil.move(os.path.join(old_path, file_format.name + '.' + file_format.format.lower()),
  File "/usr/lib/python3.12/shutil.py", line 906, in move
    copy_function(src, real_dst)
  File "/usr/lib/python3.12/shutil.py", line 475, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.12/shutil.py", line 260, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wróg (1508)/Wróg - Łukasz Orbitowski.epub'
[2025-04-08 11:28:38,578] ERROR {cps.editbooks:579} [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub'
Traceback (most recent call last):
  File "/usr/lib/python3.12/shutil.py", line 886, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub' -> '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Borutą - Lukasz Orbitowski.epub'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/calibre-web/cps/editbooks.py", line 464, in do_edit_book
    input_authors, author_change = handle_author_on_edit(book, to_save["authors"])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 1325, in handle_author_on_edit
    input_authors = prepare_authors(author_name, config.get_book_path(), config.config_use_google_drive)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 666, in prepare_authors
    helper.rename_all_files_on_change(one_book, new_path, new_path, all_new_name, gdrive)
  File "/app/calibre-web/cps/helper.py", line 401, in rename_all_files_on_change
    shutil.move(os.path.join(old_path, file_format.name + '.' + file_format.format.lower()),
  File "/usr/lib/python3.12/shutil.py", line 906, in move
    copy_function(src, real_dst)
  File "/usr/lib/python3.12/shutil.py", line 475, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.12/shutil.py", line 260, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub'
[2025-04-08 13:12:39,186]  INFO {cps.server:319} webserver stop (restart=False)
[2025-04-08 13:12:39,188]  INFO {apscheduler.scheduler:212} Scheduler has been shut down
[2025-04-08 13:12:39,190]  INFO {cps.server:298} Performing shutdown of Calibre-Web
[2025-04-08 13:12:57,561]  WARN {cps.config_sql:364} Log path  not valid, falling back to default
[2025-04-08 13:12:57,663]  INFO {cps:178} Starting Calibre Web...
[2025-04-08 13:12:58,664]  WARN {py.warnings:110} /lsiopy/lib/python3.12/site-packages/flask_limiter/extension.py:333: UserWarning: Using the in-memory storage for tracking rate limits as no storage was explicitly specified. This is not recommended for production use. See: https://flask-limiter.readthedocs.io#configuring-a-storage-backend for documentation about configuring the storage backend.
  warnings.warn(
[2025-04-08 13:12:59,078]  INFO {apscheduler.scheduler:181} Scheduler started
[2025-04-08 13:12:59,079]  INFO {apscheduler.scheduler:895} Added job "delete temp" to job store "default"
[2025-04-08 13:12:59,080]  INFO {apscheduler.scheduler:895} Added job "end scheduled task" to job store "default"
[2025-04-08 13:12:59,081]  INFO {apscheduler.scheduler:895} Added job "immediately delete temp" to job store "default"
[2025-04-08 13:12:59,081]  INFO {apscheduler.executors.default:123} Running job "immediately delete temp (trigger: date[2025-04-08 13:12:59 BST], next run at: 2025-04-08 13:12:59 BST)" (scheduled at 2025-04-08 13:12:59.080716+01:00)
[2025-04-08 13:12:59,081]  INFO {apscheduler.scheduler:641} Removed job 176cdcc3c76d4b348f2fb3fb042de6b0
[2025-04-08 13:12:59,121] DEBUG {cps.services.worker:91} Add Task for user: System - Clean up
[2025-04-08 13:12:59,122]  INFO {apscheduler.executors.default:144} Job "immediately delete temp (trigger: date[2025-04-08 13:12:59 BST], next run at: 2025-04-08 13:12:59 BST)" executed successfully
[2025-04-08 13:12:59,125] DEBUG {cps.tasks.clean:43} Deleted expired session_keys
[2025-04-08 13:13:02,701]  INFO {cps.server:218} Starting Gevent server on [::]:8083
[2025-04-08 13:13:23,588] ERROR {cps.editbooks:579} [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub'
Traceback (most recent call last):
  File "/usr/lib/python3.12/shutil.py", line 886, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub' -> '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Borutą - Lukasz Orbitowski.epub'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/calibre-web/cps/editbooks.py", line 464, in do_edit_book
    input_authors, author_change = handle_author_on_edit(book, to_save["authors"])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 1325, in handle_author_on_edit
    input_authors = prepare_authors(author_name, config.get_book_path(), config.config_use_google_drive)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 666, in prepare_authors
    helper.rename_all_files_on_change(one_book, new_path, new_path, all_new_name, gdrive)
  File "/app/calibre-web/cps/helper.py", line 401, in rename_all_files_on_change
    shutil.move(os.path.join(old_path, file_format.name + '.' + file_format.format.lower()),
  File "/usr/lib/python3.12/shutil.py", line 906, in move
    copy_function(src, real_dst)
  File "/usr/lib/python3.12/shutil.py", line 475, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.12/shutil.py", line 260, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub'
[2025-04-08 13:13:47,210] ERROR {cps.editbooks:579} [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub'
Traceback (most recent call last):
  File "/usr/lib/python3.12/shutil.py", line 886, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub' -> '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Borutą - Lukasz Orbitowski.epub'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/calibre-web/cps/editbooks.py", line 464, in do_edit_book
    input_authors, author_change = handle_author_on_edit(book, to_save["authors"])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 1325, in handle_author_on_edit
    input_authors = prepare_authors(author_name, config.get_book_path(), config.config_use_google_drive)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 666, in prepare_authors
    helper.rename_all_files_on_change(one_book, new_path, new_path, all_new_name, gdrive)
  File "/app/calibre-web/cps/helper.py", line 401, in rename_all_files_on_change
    shutil.move(os.path.join(old_path, file_format.name + '.' + file_format.format.lower()),
  File "/usr/lib/python3.12/shutil.py", line 906, in move
    copy_function(src, real_dst)
  File "/usr/lib/python3.12/shutil.py", line 475, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.12/shutil.py", line 260, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub'
[2025-04-08 13:13:53,047]  WARN {cps.services.goodreads_support:109} Goodreads website is down/inaccessible? ('api/author_url/Łukasz Orbitowski', ':', 'Unauthorized')
[2025-04-08 13:13:59,940] ERROR {cps.helper:960} File not found: /books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub
[2025-04-08 13:14:03,322] ERROR {cps.helper:960} File not found: /books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.mobi
[2025-04-08 13:14:42,027] ERROR {cps.helper:960} File not found: /books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub
[2025-04-08 13:20:32,696] DEBUG {cps.ub:96} Deleted session_key: da360cf60d4fa74907f349a2e6e9aabb88beac37ea3c5d8d1d7fff1bd0c3009f3ae7059caa50d24f729ff345e6277b0452598a77e98a5b45dd4e8e3c8cbe8027
[2025-04-08 13:20:32,703] DEBUG {cps.web:1459} User logged out
[2025-04-08 13:20:35,391] DEBUG {cps.web:1440} You are now logged in as: 'admin'
[2025-04-08 13:20:35,409] DEBUG {cps.ub:84} Login and store session : da360cf60d4fa74907f349a2e6e9aabb88beac37ea3c5d8d1d7fff1bd0c3009f3ae7059caa50d24f729ff345e6277b0452598a77e98a5b45dd4e8e3c8cbe8027
[2025-04-08 13:20:42,521] DEBUG {cps.updater:331} Stable version: 0.6.24
[2025-04-08 13:20:52,141] DEBUG {cps.ub:96} Deleted session_key: da360cf60d4fa74907f349a2e6e9aabb88beac37ea3c5d8d1d7fff1bd0c3009f3ae7059caa50d24f729ff345e6277b0452598a77e98a5b45dd4e8e3c8cbe8027
[2025-04-08 13:20:52,155] DEBUG {cps.web:1459} User logged out
[2025-04-08 13:20:54,886] DEBUG {cps.web:1440} You are now logged in as: 'dinth'
[2025-04-08 13:20:54,900] DEBUG {cps.ub:84} Login and store session : da360cf60d4fa74907f349a2e6e9aabb88beac37ea3c5d8d1d7fff1bd0c3009f3ae7059caa50d24f729ff345e6277b0452598a77e98a5b45dd4e8e3c8cbe8027
[2025-04-08 13:20:55,282] DEBUG {cps.web:1440} You are now logged in as: 'dinth'
[2025-04-08 13:20:55,298] DEBUG {cps.ub:84} Login and store session : da360cf60d4fa74907f349a2e6e9aabb88beac37ea3c5d8d1d7fff1bd0c3009f3ae7059caa50d24f729ff345e6277b0452598a77e98a5b45dd4e8e3c8cbe8027
[2025-04-08 13:24:48,191] ERROR {cps.editbooks:579} [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub'
Traceback (most recent call last):
  File "/usr/lib/python3.12/shutil.py", line 886, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub' -> '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Borutą - Lukasz Orbitowski.epub'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/calibre-web/cps/editbooks.py", line 464, in do_edit_book
    input_authors, author_change = handle_author_on_edit(book, to_save["authors"])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 1325, in handle_author_on_edit
    input_authors = prepare_authors(author_name, config.get_book_path(), config.config_use_google_drive)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 666, in prepare_authors
    helper.rename_all_files_on_change(one_book, new_path, new_path, all_new_name, gdrive)
  File "/app/calibre-web/cps/helper.py", line 401, in rename_all_files_on_change
    shutil.move(os.path.join(old_path, file_format.name + '.' + file_format.format.lower()),
  File "/usr/lib/python3.12/shutil.py", line 906, in move
    copy_function(src, real_dst)
  File "/usr/lib/python3.12/shutil.py", line 475, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.12/shutil.py", line 260, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub'
[2025-04-08 13:25:32,026]  WARN {cps.services.goodreads_support:109} Goodreads website is down/inaccessible? ('api/author_url/Łukasz Orbitowski', ':', 'Unauthorized')
[2025-04-08 13:26:45,084] ERROR {cps.helper:960} File not found: /books/!Calibre/Lukasz Orbitowski/Wywiad z Boruta (427)/Wywiad z Boruta - Lukasz Orbitowski.epub
[2025-04-08 13:31:52,575] DEBUG {cps.ub:96} Deleted session_key: da360cf60d4fa74907f349a2e6e9aabb88beac37ea3c5d8d1d7fff1bd0c3009f3ae7059caa50d24f729ff345e6277b0452598a77e98a5b45dd4e8e3c8cbe8027
[2025-04-08 13:31:52,607] DEBUG {cps.web:1459} User logged out
[2025-04-08 13:31:55,254] DEBUG {cps.web:1440} You are now logged in as: 'admin'
[2025-04-08 13:31:55,271] DEBUG {cps.ub:84} Login and store session : da360cf60d4fa74907f349a2e6e9aabb88beac37ea3c5d8d1d7fff1bd0c3009f3ae7059caa50d24f729ff345e6277b0452598a77e98a5b45dd4e8e3c8cbe8027

Expected behavior

The newly added book should save without a problem, the previously added book should have files accessible

Environment (please complete the following information):

  • OS: Debian Linux
  • Calibre-Web version: [e.g. 0.6.8 or 087c4c5 (git rev-parse --short HEAD)]: 0.6.24
  • Docker container: [None/LinuxServer]: LinuxServer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions