janeczku / calibre-web

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

Kobo Sync Books Failing To Sync; "No such file or directory:..." | Proxmox, Docker, NAS #3040

Closed Outsmart2383 closed 5 months ago

Outsmart2383 commented 5 months ago

My set up I'm running Calibre-Web in Docker, on a Debian VM on Proxmox. Books stored on a Synology NAS which is mounted to the VM.

Describe the bug/problem

I have Calibre-Web (and thus Calibre also) up and running, and my books display correctly in Calibre Web. The bookcovers do not (I get "Cover not available"), I'm not bothered by this, but I think it may be related/caused by the same issue.

I have taken all typical steps to get Kobo Sync working, by Enabling it, modifying my Kobo configuration file etc. and when I click Sync on my Kobo, I don't get a failed sync error, the sync completes and the shelf I have created in Calibre-Web appears on my Kobo. However, no books appears.

Here's what the logs say:

[2024-05-01 16:06:21,062]  INFO {cps.ub:911} 2 sync entries deleted
[2024-05-01 16:06:28,683]  INFO {cps.kobo:1042} Init
[2024-05-01 16:06:30,824]  INFO {cps.kobo:143} Kobo library sync request received.
[2024-05-01 16:06:30,835] ERROR {cps.kobo:456} [Errno 2] No such file or directory: '/db/author/book.epub'
[2024-05-01 16:06:30,835] ERROR {cps.kobo:456} [Errno 2] No such file or directory:'/db/author/book.epub'
[2024-05-01 16:06:30,844] ERROR {cps.kobo:456} [Errno 2] No such file or directory: '/db/author/book.epub'
[2024-05-01 16:06:30,844] ERROR {cps.kobo:456} [Errno 2] No such file or directory: '/db/author/book.epub'

I suspect I understand the cause. Calibre-Web is looking for the books in my /db directory. However, they don't exist there. Because I'm using a NAS. More so, when I'm in Calibre-Web, if I click to "download" the EPUB I get an error:

Calibre-Web
Error 404
Not Found

and the logs display broadly the same error as when trying to sync:

[2024-05-01 16:29:58,769] ERROR {cps.helper:953} File not found: /db/author/book.epub
[2024-05-01 16:30:39,473] ERROR {cps.helper:953} File not found: /db/author/book.epub

So I suspect the issue probably resides in my Docker Compose, however I'm not sure where to go from here, because I found it very difficult to get Calibre working with my NAS in the first place. Any advice or suggestions would be greatly appreciated:

  calibre:
    image: lscr.io/linuxserver/calibre:latest
    container_name: calibre
    network_mode: "service:gluetun"
    security_opt:
      - seccomp:unconfined
    environment:
      - PUID=0
      - PGID=0
      - TZ=Europe/London
      - CALIBRE_OVERRIDE_DATABASE_PATH=/db/metadata.db
    volumes:
      - /home/ubuntu/docker/arr-stack/calibre/data:/config
      - /data/calibre/db:/db
      - /data/mnt/books:/books
      - /mnt/arr/Media/Books/eBooks:/mnt/arr/Media/Books/eBooks
    restart: unless-stopped

  calibre-web:
    image: ghcr.io/linuxserver/calibre-web
    container_name: calibre-web
    network_mode: "service:gluetun"
    environment:
      - PUID=0
      - PGID=0
    volumes:
      - /data/calibre/db:/db
      - /home/ubuntu/docker/arr-stack/calibre/calibre-web:/config
      - /mnt/arr/Media/Books/eBooks:/mnt/arr/Media/Books/eBooks
    restart: unless-stopped
    depends_on:
      - calibre
Outsmart2383 commented 5 months ago

Okay, so I'm starting to wonder if this is possibly a limitation of Calibre-Web?

I have to use the - CALIBRE_OVERRIDE_DATABASE_PATH=/db/metadata.db entry, because my books are stored on my NAS, and this doesn't play nicely with the database file.

But Calibre web expects my books to be stored in the directory of the database file, as that is the usual approach.

Does that seem to be correct? (I'm just surprised I'm the first person in the situation if it is!)

If so... feature request?

Outsmart2383 commented 5 months ago

Not a novel issue: https://github.com/janeczku/calibre-web/issues/1462

Outsmart2383 commented 5 months ago

I have tried to implement this as a solution: https://github.com/janeczku/calibre-web/issues/1462#issuecomment-980347842

So for me I mapped: - /data/calibre/db/metadata.db:/mnt/arr/Media/Books/eBooks/metadata.db

I then went into Calibre-Web and set my Location of Calibre Database to /mnt/arr/Media/Books/eBooks/metadata.db

But now I get:

Calibre-Web
500 Internal Server Error
The server encountered an internal error and was unable to complete your request. There is an error in the application.
Traceback (most recent call last):
File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/app/calibre-web/cps/usermanagement.py", line 35, in decorated_view
return login_required(func)(*args, **kwargs)
File "/lsiopy/lib/python3.10/site-packages/flask_login/utils.py", line 290, in decorated_view
return current_app.ensure_sync(func)(*args, **kwargs)
File "/app/calibre-web/cps/web.py", line 790, in index
return render_books_list("newest", sort_param, 1, page)
File "/app/calibre-web/cps/web.py", line 408, in render_books_list
entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books, True, order[0],
File "/app/calibre-web/cps/db.py", line 803, in fill_indexpage
return self.fill_indexpage_with_archived_books(page, database, pagesize, db_filter, order, False,
File "/app/calibre-web/cps/db.py", line 810, in fill_indexpage_with_archived_books
random_query = self.generate_linked_query(config_read_column, database)
File "/app/calibre-web/cps/db.py", line 764, in generate_linked_query
query = (self.session.query(database, ub.ArchivedBook.is_archived, ub.ReadBook.read_status)
AttributeError: 'NoneType' object has no attribute 'query'
Please report this issue with all related information: [Create Issue](https://github.com/janeczku/calibre-web/issues/new/choose)

Must have done something wrong, as the metadata.db file in /mnt/arr/Media/Books/eBooks is empty.

Outsmart2383 commented 5 months ago

Okay, so reverting back to this: https://github.com/janeczku/calibre-web/issues/1462

I pulled the master branch (whereas I was previously running on latest), and in Calibre-Web in Edit Calibe Database Configuration there is now an option for Separate Book Files from Library and this can be used for selecting the books on the NAS.