Calibre corrupts last modified date when using the server

Bug #2031341 reported by Ross King
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

I have a fairly specific bug, that is not completely consistent, and only occurs in certain circumstances.

When starting the server from the main calibre UI, when requesting a book using calibredb including the last_modified field, it returns an error.

Traceback (most recent call last):
  File "runpy.py", line 196, in _run_module_as_main
  File "runpy.py", line 86, in _run_code
  File "site.py", line 83, in <module>
  File "site.py", line 78, in main
  File "site.py", line 50, in run_entry_point
  File "calibre\db\cli\main.py", line 252, in main
  File "calibre\db\cli\main.py", line 40, in run_cmd
  File "calibre\db\cli\cmd_list.py", line 362, in main
  File "calibre\db\cli\cmd_list.py", line 175, in do_list
  File "calibre\db\cli\main.py", line 183, in run
  File "calibre\db\cli\main.py", line 206, in remote_run
  File "calibre\utils\serialize.py", line 107, in msgpack_loads
  File "msgpack/_unpacker.pyx", line 194, in msgpack._cmsgpack.unpackb
  File "calibre\utils\serialize.py", line 101, in msgpack_decoder
  File "calibre\utils\serialize.py", line 83, in decode_datetime
  File "calibre\utils\iso8601.py", line 26, in parse_iso8601
TypeError: timezone() argument 1 must be datetime.timedelta, not int

If I close calibre, and start the server with the command

calibre-server --disable-use-bonjour --enable-local-write --listen-on 127.0.0.1

and then rerun the same calibredb command, it does not occur.

This only occurs when requesting the last_modified date, and only when starting the server through the main calibre program.

This means that scripts are unable to find the searched book.

calibre version - 6.24.0
operating system - Windows 11 22H2

Revision history for this message
Kovid Goyal (kovid) wrote :

What is the calibredb command you are using?

Changed in calibre:
status: New → Incomplete
Revision history for this message
mva base (mvabase) wrote :

I receive a similar error report when trying to update the tags on a book via the command:

/Applications/calibre.app/Contents/MacOS/calibredb set_metadata --field tags:"test" --with-library='http://localhost:5070/#5_Civil_rights' 2161

But the tags are nevertheless updated.

Error report:
Traceback (most recent call last):
  File "runpy.py", line 196, in _run_module_as_main
  File "runpy.py", line 86, in _run_code
  File "site.py", line 41, in <module>
  File "site.py", line 37, in main
  File "calibre/db/cli/main.py", line 252, in main
  File "calibre/db/cli/main.py", line 40, in run_cmd
  File "calibre/db/cli/cmd_set_metadata.py", line 179, in main
  File "calibre/db/cli/main.py", line 183, in run
  File "calibre/db/cli/main.py", line 206, in remote_run
  File "calibre/utils/serialize.py", line 107, in msgpack_loads
  File "msgpack/_unpacker.pyx", line 194, in msgpack._cmsgpack.unpackb
  File "calibre/utils/serialize.py", line 101, in msgpack_decoder
  File "calibre/utils/serialize.py", line 107, in msgpack_loads
  File "msgpack/_unpacker.pyx", line 194, in msgpack._cmsgpack.unpackb
  File "calibre/utils/serialize.py", line 101, in msgpack_decoder
  File "calibre/utils/serialize.py", line 83, in decode_datetime
  File "calibre/utils/iso8601.py", line 26, in parse_iso8601
TypeError: timezone() argument 1 must be datetime.timedelta, not int

macOS Ventura - latest version of Calibre

Revision history for this message
Ross King (rsking) wrote :

I've come up with the simplest repo that I could

1. Create a new library called Test
2. start calibre server with the command
  `calibre-server --enable-local-write`
3. Download a book,
  `curl https://standardebooks.org/ebooks/honore-de-balzac/shorts-from-scenes-from-private-life/clara-bell_ellen-marriage/downloads/honore-de-balzac_shorts-from-scenes-from-private-life_clara-bell_ellen-marriage.epub -O`
4. Add the book to the `Test` library
  `calibredb add --with-library http://127.0.0.1:8080/#Test .\honore-de-balzac_shorts-from-scenes-from-private-life_clara-bell_ellen-marriage.epub`
5. try to retrieve information about the added book, including the last modified field
  `calibredb list --with-library http://127.0.0.1:8080/#Test --fields=last_modified --search=id:"=1"`

This results in the failure

Traceback (most recent call last):
  File "runpy.py", line 196, in _run_module_as_main
  File "runpy.py", line 86, in _run_code
  File "site.py", line 83, in <module>
  File "site.py", line 78, in main
  File "site.py", line 50, in run_entry_point
  File "calibre\db\cli\main.py", line 252, in main
  File "calibre\db\cli\main.py", line 40, in run_cmd
  File "calibre\db\cli\cmd_list.py", line 362, in main
  File "calibre\db\cli\cmd_list.py", line 175, in do_list
  File "calibre\db\cli\main.py", line 183, in run
  File "calibre\db\cli\main.py", line 206, in remote_run
  File "calibre\utils\serialize.py", line 107, in msgpack_loads
  File "msgpack/_unpacker.pyx", line 194, in msgpack._cmsgpack.unpackb
  File "calibre\utils\serialize.py", line 101, in msgpack_decoder
  File "calibre\utils\serialize.py", line 83, in decode_datetime
  File "calibre\utils\iso8601.py", line 26, in parse_iso8601
TypeError: timezone() argument 1 must be datetime.timedelta, not int

Revision history for this message
Ross King (rsking) wrote :

same result using `show_metadata` after adding the book

`calibredb show_metadata --with-library http://127.0.0.1:8080/#Test 1`

results in

Traceback (most recent call last):
  File "runpy.py", line 196, in _run_module_as_main
  File "runpy.py", line 86, in _run_code
  File "site.py", line 83, in <module>
  File "site.py", line 78, in main
  File "site.py", line 50, in run_entry_point
  File "calibre\db\cli\main.py", line 252, in main
  File "calibre\db\cli\main.py", line 40, in run_cmd
  File "calibre\db\cli\cmd_show_metadata.py", line 46, in main
  File "calibre\db\cli\main.py", line 183, in run
  File "calibre\db\cli\main.py", line 206, in remote_run
  File "calibre\utils\serialize.py", line 107, in msgpack_loads
  File "msgpack/_unpacker.pyx", line 194, in msgpack._cmsgpack.unpackb
  File "calibre\utils\serialize.py", line 101, in msgpack_decoder
  File "calibre\utils\serialize.py", line 107, in msgpack_loads
  File "msgpack/_unpacker.pyx", line 194, in msgpack._cmsgpack.unpackb
  File "calibre\utils\serialize.py", line 101, in msgpack_decoder
  File "calibre\utils\serialize.py", line 83, in decode_datetime
  File "calibre\utils\iso8601.py", line 26, in parse_iso8601
TypeError: timezone() argument 1 must be datetime.timedelta, not int

Revision history for this message
Kovid Goyal (kovid) wrote :

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

Changed in calibre:
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.