MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Library Management (https://www.mobileread.com/forums/forumdisplay.php?f=236)
-   -   Calibre Sort by Size Not Refreshing (https://www.mobileread.com/forums/showthread.php?t=265838)

eucalyptus 09-30-2015 02:18 AM

Calibre Sort by Size Not Refreshing
 
Hello! I was wondering if anyone would know how to fix this:

I noticed the other day that some of my ebooks were humongous in size, so I added a 'size' column in Calibre and sorted them by size. Then I started individually opening each folder and trimming the ebooks down in size (removing custom fonts and jpegs from epubs, etc.).

I noticed, though, that even though I restarted Calibre and the computer, Calibre still displays the old size of the files in the 'size' sorting column. It still says, for instance, 82 mb for a file that is now only 2 mb.

How do I make Calibre show the actual, updated file size for each ebook?

kovidgoyal 09-30-2015 02:20 AM

The size column in calibre is only updated when you add/remove a book format. IIRC the quality check plugin has an option to scan the library and update that info.

eucalyptus 09-30-2015 08:41 AM

I see, thank you, will check out that plugin!

gingerbeardman 11-11-2017 11:58 AM

Did you solve this? I have this issue also.

theducks 11-11-2017 03:02 PM

Quote:

Originally Posted by gingerbeardman (Post 3609936)
Did you solve this? I have this issue also.

That was an ancient post. The answer Kovid gave is still relevant. QC PI
FWIW the size also updates after a Tweak-book (Calibre Editor)

gingerbeardman 11-11-2017 03:46 PM

It was an ancient post without a confirmed resolution.

I'm working with PDFs rather than ePubs.

https://www.mobileread.com/forums/sh...d.php?t=292065

Kovid's "add/remove a book format" does not seem to work for PDFs.

I've tried QC PI and had no luck. Which option have you seen resolve this size issue?

And I don't think Tweak Books is in the latest Calibre?

Any help appreciated.

gingerbeardman 11-11-2017 04:37 PM

data is at:

metadata.db
TABLE data
COLUMN uncompressed_size

theducks 11-11-2017 05:53 PM

Quote:

Originally Posted by gingerbeardman (Post 3610036)
It was an ancient post without a confirmed resolution.

I'm working with PDFs rather than ePubs.

https://www.mobileread.com/forums/sh...d.php?t=292065

Kovid's "add/remove a book format" does not seem to work for PDFs.

I've tried QC PI and had no luck. Which option have you seen resolve this size issue?

And I don't think Tweak Books is in the latest Calibre?

Any help appreciated.

T is the shortcut for the editor, U is the Old Tweak Books (unpack)

Neither work on PDF. (which was not mentioned in post 1)

kovidgoyal 11-11-2017 11:53 PM

The size calibre displays is a not a file size, it is the size of the largest of a book's files, and it is updated when you add/remove a format, regardless of what format the book is in.

gingerbeardman 11-12-2017 06:09 AM

I ended up using "restore database" in the Calibre Library menu

thanks all

jindroush 07-14-2020 03:10 PM

Refresh size
 
I KNOW ;) that I'm reopening years old thread.

I have the same problem as OP, I modify files directly in Calibre library directory.

Tried to use (most probably abandoned) QualityCheck plugin, it does not work on current Calibre, because it calls:

formats = db.formats(book_id, index_is_id=True, verify_formats=False)
for fmt in formats.split(','):
db_size = db.sizeof_format(book_id, fmt, index_is_id=True)

but that is implemented in legacy.py as filesystem read, instead of table read. So this check is always 'good', because it compares disk size to disk size and thus does not fix db.

So question, directly to Kovid, if possible: With what call should be db.sizeof_format replaced with to get data from uncompressed_size column?

Thx,
J.

BetterRed 07-14-2020 06:36 PM

Quote:

Originally Posted by jindroush (Post 4011739)
I KNOW ;) that I'm reopening years old thread.

I have the same problem as OP, I modify files directly in Calibre library directory.

Tried to use (most probably abandoned) QualityCheck plugin, it does not work on current Calibre, because it calls:

Moderator Notice
The QC PI will need to be updated to support Python 3 used the upcoming Calibre 5 release. One of the active PI developers will do that… I hope ;)

BR

jindroush 07-15-2020 05:38 AM

Fix
 
So I replaced this line (in QualityCheck.zip/check_fix.py)

db_size = db.sizeof_format(book_id, fmt, index_is_id=True)

with

db_size = next(db.backend.execute( "SELECT uncompressed_size FROM data WHERE book=? AND format=?", ( book_id, fmt ) ))[0]

which does what I need in QualityCheck/Fix/Check and repair file sizes. I wasn't able to do that using any LibraryDatabase or Cache call.

kovidgoyal 07-15-2020 05:46 AM

You use format_metadata() Note that uncompressed_size is not actually used for anything. Sizes of individual format files are read from the filesystem with a cache for performance.

jindroush 07-15-2020 06:38 AM

Quote:

Originally Posted by kovidgoyal (Post 4011972)
You use format_metadata() Note that uncompressed_size is not actually used for anything. Sizes of individual format files are read from the filesystem with a cache for performance.

Yes, this is what I found out. But the logic in QualityCheck is basically based on assumption that there is a difference between 'uncompressed_size' and actual filesystem size and this is what it checks and tries to repair, and that there is a method of getting 'uncompressed_size'. It seems that this logic is based on the past behaviour of Calibre, and since the plugin seems to be abandoned, it's not working anymore.

With the fix I made, uncompress_size and also the max of all formats are updated, which makes me happy (since I use sqlite db dump of metadata.db to do some other checks externally).


All times are GMT -4. The time now is 06:10 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.