Fix regression in Sony device-pane metadata editing

This commit is contained in:
Charles Haley 2010-07-02 10:16:23 +01:00
parent d000fbc7b2
commit 2a0936f14f

View File

@ -350,9 +350,7 @@ class XMLCache(object):
record = lpath_map.get(book.lpath, None) record = lpath_map.get(book.lpath, None)
if record is None: if record is None:
record = self.create_text_record(root, i, book.lpath) record = self.create_text_record(root, i, book.lpath)
date = self.check_timestamp(record, book, path) self.update_text_record(record, book, path, i)
if date is not None:
self.update_text_record(record, book, date, path, i)
# Ensure the collections in the XML database are recorded for # Ensure the collections in the XML database are recorded for
# this book # this book
if book.device_collections is None: if book.device_collections is None:
@ -443,22 +441,14 @@ class XMLCache(object):
root.append(ans) root.append(ans)
return ans return ans
def check_timestamp(self, record, book, path): def update_text_record(self, record, book, path, bl_index):
'''
Checks the timestamp in the Sony DB against the file. If different,
return the file timestamp. Otherwise return None.
'''
timestamp = os.path.getmtime(path)
date = strftime(timestamp)
if date != record.get('date', None):
return date
return None
def update_text_record(self, record, book, date, path, bl_index):
''' '''
Update the Sony database from the book. This is done if the timestamp in Update the Sony database from the book. This is done if the timestamp in
the db differs from the timestamp on the file. the db differs from the timestamp on the file.
''' '''
timestamp = os.path.getmtime(path)
date = strftime(timestamp)
if date != record.get('date', None):
record.set('date', date) record.set('date', date)
record.set('size', str(os.stat(path).st_size)) record.set('size', str(os.stat(path).st_size))
title = book.title if book.title else _('Unknown') title = book.title if book.title else _('Unknown')