Fix catalog date issues

This commit is contained in:
Kovid Goyal 2010-02-18 10:12:48 -07:00
parent d45da57047
commit 40e3b163fa
2 changed files with 12 additions and 10 deletions

View File

@ -139,12 +139,11 @@ class FileTypePlugin(Plugin):
#: to the database #: to the database
on_import = False on_import = False
#: If True, this plugin is run whenever an any2* tool #: If True, this plugin is run just before a conversion
#: is used, on the file passed to the any2* tool.
on_preprocess = False on_preprocess = False
#: If True, this plugin is run after an any2* tool is #: If True, this plugin is run after conversion
#: used, on the final file produced by the tool. #: on the final file produced by the conversion output plugin.
on_postprocess = False on_postprocess = False
type = _('File type') type = _('File type')

View File

@ -1475,18 +1475,21 @@ class LibraryDatabase2(LibraryDatabase):
self.data.books_added([db_id], self) self.data.books_added([db_id], self)
self.set_path(db_id, index_is_id=True) self.set_path(db_id, index_is_id=True)
self.conn.commit() self.conn.commit()
try:
mi = get_metadata(stream,
os.path.splitext(path)[1][1:].lower())
except:
mi = MetaInformation(title, ['calibre']) mi = MetaInformation(title, ['calibre'])
mi.title, mi.authors = title, ['calibre']
mi.tags = [_('Catalog')] mi.tags = [_('Catalog')]
mi.pubdate = mi.timestamp = nowf()
self.set_metadata(db_id, mi) self.set_metadata(db_id, mi)
self.add_format(db_id, format, stream, index_is_id=True) self.add_format(db_id, format, stream, index_is_id=True)
if not hasattr(path, 'read'): if not hasattr(path, 'read'):
stream.close() stream.close()
self.conn.commit() self.conn.commit()
if existing:
t = utcnow()
self.set_timestamp(db_id, t, notify=False)
self.set_pubdate(db_id, t, notify=False)
self.data.refresh_ids(self, [db_id]) # Needed to update format list and size self.data.refresh_ids(self, [db_id]) # Needed to update format list and size
return db_id return db_id