janeczku / calibre-web

:books: Web app for browsing, reading and downloading eBooks stored in a Calibre database
GNU General Public License v3.0
12.99k stars 1.39k forks source link

Database in readonly on latest version, unable to upload #2069

Closed ServerGeek82 closed 2 years ago

ServerGeek82 commented 3 years ago

Describe the bug/problem Unable to upload new book to library, database is possibly in read-only

root@273c80d5ca21:/# touch /books/file.pdf root@273c80d5ca21:/# rm /books/file.pdf root@273c80d5ca21:/# touch config/file root@273c80d5ca21:/# rm config/file root@273c80d5ca21:/# ls -la /books/metadata.db -rwxr--r-- 1 abc abc 659456 Jul 25 15:13 /books/metadata.db root@273c80d5ca21:/#

As seen above I am able to create, and remove files from both the book (library), and config directory of the container.

From settings I am able to use the "reconnect to database" and message shows "successful" Attached is the debug log from settings.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Add new book (upload)'
  2. Click on 'Select book'
  3. Scroll down to '....'
  4. See error

Logfile see attachment

Expected behavior Ability to add new content.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context Help > About page Program Library Installed Version Platform Linux 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021 x86_64 x86_64 Python 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0] Calibre_Web 0.6.12 - 54d06e580d73ba58274e7ed4efbd8fc94b7e1856 - 2021-05-22T14:08:46+02:00 WebServer Gevent 21.1.2 Flask 1.1.4 Flask_Login 0.5.0 Flask_Principal 0.4.0 Werkzeug 1.0.1 Babel 2.9.1 Jinja2 2.11.3 Requests 2.24.0 SqlAlchemy 1.4.20 pySqlite 2.6.0 SQLite 3.31.1 iso639 0.4.5 pytz 2021.1 Unidecode installed Flask_SimpleLDAP installed python_LDAP 3.3.1 Goodreads installed jsonschema 3.2.0 flask_dance 5.0.0 greenlet 1.1.0 Image Magick ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org PyPdf v1.0.3 lxml v4.6.3.0 Wand 0.6.6 Comic_API 2.2.0 ebook converter ebook-convert (calibre 5.23.0) unrar UNRAR 5.61 beta 1 freeware Copyright (c) 1993-2018 Alexander Roshal kepubify not installed Calibre-Web-debug-pack.zip

OzzieIsaacs commented 3 years ago

As seen above I am able to create, and remove files from both the book (library), and config directory of the container.

Understandable, as you are root, which user is running the calibre-web instance. Can this user do it?

From settings I am able to use the "reconnect to database" and message shows "successful"

Understandable, as it only reopens the books database.

From the logbooks May, 30th: The Error message is very clear attempt to write a readonly database. Digging deeper into it, it turned out that this error is referring app.db. Calibre-web only has read access to the app.db file.

Furthermore I see a UNIQUE constraint failed: authors.name, please consider to perform a database check from calibre destop program itself, looks like there is something wrong.

Rename file in path /books/Unknown/EVERYT~3 (245) to EVERYT~3 - Unknown: [Errno 2] No such file or directory: '/books/Unknown/EVERYT~3 (245)/EVERYT~3.pdf' -> If this is your error please check if the file EVERYT~3 is really there, my guess it's not there, so it can't be moved, could be a consequential failure because of other errors. Please perform a database check from calibre desktop app.


From July, 25th. I can't see any entries regarding failed book upload. I doublechecked it in the code, if there is some database action going wrong, there should be a log entry. So please paste a screenshot with the exact error message shown on the screen, so I can check where it comes from. And please check if the database later on has the book entry and if the book is moved to the folder structure.

If it's attempt to write to readonly database, then most likely this is a docker access right problem, there are dozens of issues regarding this. I'm not the docker container maintainer, so I can't help you with this.

ServerGeek82 commented 3 years ago

good call out. root@273c80d5ca21:/# su abc touch /books/file.pdf root@273c80d5ca21:/# su abc rm /books/file.pdf root@273c80d5ca21:/# su abc touch /config/file root@273c80d5ca21:/# su abc rm /config/file

ServerGeek82 commented 3 years ago

root@273c80d5ca21:/# ls -la /books/metadata.db -rwxrwxrwx 1 abc abc 659456 Jul 26 10:17 /books/metadata.db root@273c80d5ca21:/# ls -la /tmp/calibre_web/ total 8 drwxr-xr-x 2 abc abc 4096 Jul 26 10:17 . drwxrwxrwt 1 root root 4096 Jul 26 10:17 .. root@273c80d5ca21:/#

Error for calibre-web on upload "Oops! Selected book title is unavailable. File does not exist or is not accessible"

From calibre logs file [2021-07-26 10:18:46,816] DEBUG {cps.helper:368} Moving title: /tmp/calibre_web/7f70815b36f7aca7a6eacbd87e1bb48a to /books/Unknown/Book Title. by Richards Thomas. (306)/book title. by Richards Thomas. - Unknown [2021-07-26 10:18:46,828] DEBUG {cps.services.worker:72} Add Task for user: admin: <cps.tasks.upload.TaskUpload object at 0x7f5e72e28ca0> [2021-07-26 10:19:35,407] DEBUG {cps.web:1767} Oops! Selected book title is unavailable. File does not exist or is not accessible [2021-07-26 10:19:55,101] DEBUG {cps.updater:303} Stable version: {'version': '0.6.12'}

OzzieIsaacs commented 2 years ago

I fixed several bugs in conjunction with read only databases

subdiox commented 2 years ago

@OzzieIsaacs Please reopen this issue, because I've encountered almost the same issue as this one. Version: 2022/05/04 1:43 OS: RockyLinux 8.5

  1. Login with non-admin user
  2. Click upload button
  3. Select cbz file

After the loading bar is complete, the following error message is shown: Oops! Selected book title is unavailable. File does not exist or is not accessible

I tried not to use docker container and launched the server manually, but the same issue occurred.

OzzieIsaacs commented 2 years ago

If the database is readonly how do you think calibre-web shall save the book information? Of course this isn‘t working

subdiox commented 2 years ago

The explanation of readonly might be incorrect, but the error has actually occurred. What do you think about the fact that admin user can access all contents but non-admin users can't access some of them?

OzzieIsaacs commented 2 years ago

You can restrict the visible book languages in the users setting, with this not all books are visible. But if this occurs on upload the books language should get changed. Another possibility would be if you have a restriction on only certain categories are visible to a user, the new book doesn‘t have the category and isn‘t visible therefore

subdiox commented 2 years ago

I've solved the problem completely by changing the user settings of "Language of books". Thank you very much for your precise advice!