mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
SONY XML cache: Handle case where XML db contains reference to a file that does not exist gracefully
This commit is contained in:
parent
c2a80c1e7b
commit
8573807497
@ -610,7 +610,11 @@ class XMLCache(object):
|
||||
# is not new, compare its Sony DB date against localtime and gmtime.
|
||||
# Count the matches. When we must set a date, use the one with the most
|
||||
# matches. Use localtime if the case of a tie, and hope it is right.
|
||||
try:
|
||||
timestamp = os.path.getmtime(path)
|
||||
except:
|
||||
debug_print('Failed to get timestamp for:', path)
|
||||
timestamp = time.time()
|
||||
rec_date = record.get('date', None)
|
||||
|
||||
def clean(x):
|
||||
@ -646,7 +650,10 @@ class XMLCache(object):
|
||||
debug_print("Use GMT TZ for new book", book.lpath)
|
||||
date = strftime(timestamp, zone=tz)
|
||||
record.set('date', clean(date))
|
||||
try:
|
||||
record.set('size', clean(str(os.stat(path).st_size)))
|
||||
except:
|
||||
record.set('size', '0')
|
||||
title = book.title if book.title else _('Unknown')
|
||||
record_set('title', title)
|
||||
ts = book.title_sort
|
||||
|
Loading…
x
Reference in New Issue
Block a user