IGN:Delete library1.db after migration if it was empty

This commit is contained in:
Kovid Goyal 2008-09-01 21:21:04 -07:00
parent 65977f0133
commit a24e9c0c7c
3 changed files with 8 additions and 3 deletions

View File

@ -163,7 +163,7 @@ def option_parser(usage, gui_mode=False):
help=_('''The regular expression used to detect chapter titles.''' help=_('''The regular expression used to detect chapter titles.'''
''' It is searched for in heading tags (h1-h6). Defaults to %default''')) ''' It is searched for in heading tags (h1-h6). Defaults to %default'''))
chapter.add_option('--chapter-attr', default='$,,$', chapter.add_option('--chapter-attr', default='$,,$',
help=_('Detect a chapter beginning at an element having the specified attribute. The format for this option is tagname regexp,attribute name,attribute value regexp. For example to match all heading tags that have the attribute class="chapter" you would use "h\d,class,chapter". You can set the attrivute to "none" to match only on tag names. So for example, to match all <h2> tags, you would use "h2,none,". Default is %default''')) help=_('Detect a chapter beginning at an element having the specified attribute. The format for this option is tagname regexp,attribute name,attribute value regexp. For example to match all heading tags that have the attribute class="chapter" you would use "h\d,class,chapter". You can set the attribute to "none" to match only on tag names. So for example, to match all <h2> tags, you would use "h2,none,". Default is %default'''))
chapter.add_option('--page-break-before-tag', dest='page_break', default='h[12]', chapter.add_option('--page-break-before-tag', dest='page_break', default='h[12]',
help=_('''If html2lrf does not find any page breaks in the ''' help=_('''If html2lrf does not find any page breaks in the '''
'''html file and cannot detect chapter headings, it will ''' '''html file and cannot detect chapter headings, it will '''

View File

@ -225,7 +225,10 @@ class Main(MainWindow, Ui_MainWindow):
pd.setCancelButton(None) pd.setCancelButton(None)
pd.setWindowTitle(_('Migrating database')) pd.setWindowTitle(_('Migrating database'))
pd.show() pd.show()
db.migrate_old(self.olddb, pd) number_of_books = db.migrate_old(self.olddb, pd)
self.olddb.close()
if number_of_books == 0:
os.remove(self.olddb.dbpath)
self.olddb = None self.olddb = None
prefs['library_path'] = self.library_path prefs['library_path'] = self.library_path
self.library_view.sortByColumn(3, Qt.DescendingOrder) self.library_view.sortByColumn(3, Qt.DescendingOrder)
@ -1097,7 +1100,7 @@ class Main(MainWindow, Ui_MainWindow):
self.library_view.set_visible_columns(d.final_columns) self.library_view.set_visible_columns(d.final_columns)
self.tool_bar.setIconSize(config['toolbar_icon_size']) self.tool_bar.setIconSize(config['toolbar_icon_size'])
self.tool_bar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon if config['show_text_in_toolbar'] else Qt.ToolButtonIconOnly) self.tool_bar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon if config['show_text_in_toolbar'] else Qt.ToolButtonIconOnly)
self.save_menu.actions()[2].setText(_('Save only %s format to disk')%config.get('save_to_disk_single_format').upper())
if self.library_path != d.database_location: if self.library_path != d.database_location:
try: try:
newloc = d.database_location newloc = d.database_location

View File

@ -573,4 +573,6 @@ books_series_link feeds
progress.setLabelText(_('Compacting database')) progress.setLabelText(_('Compacting database'))
self.vacuum() self.vacuum()
progress.reset() progress.reset()
return len(books)