From a24e9c0c7cdee0a3773566b45174d62926ddff4a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 1 Sep 2008 21:21:04 -0700 Subject: [PATCH] IGN:Delete library1.db after migration if it was empty --- src/calibre/ebooks/lrf/__init__.py | 2 +- src/calibre/gui2/main.py | 7 +++++-- src/calibre/library/database2.py | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/lrf/__init__.py b/src/calibre/ebooks/lrf/__init__.py index 2f0e868341..1133158c63 100644 --- a/src/calibre/ebooks/lrf/__init__.py +++ b/src/calibre/ebooks/lrf/__init__.py @@ -163,7 +163,7 @@ def option_parser(usage, gui_mode=False): help=_('''The regular expression used to detect chapter titles.''' ''' It is searched for in heading tags (h1-h6). Defaults to %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

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

tags, you would use "h2,none,". Default is %default''')) chapter.add_option('--page-break-before-tag', dest='page_break', default='h[12]', help=_('''If html2lrf does not find any page breaks in the ''' '''html file and cannot detect chapter headings, it will ''' diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 6837457388..c25ea38131 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -225,7 +225,10 @@ class Main(MainWindow, Ui_MainWindow): pd.setCancelButton(None) pd.setWindowTitle(_('Migrating database')) 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 prefs['library_path'] = self.library_path 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.tool_bar.setIconSize(config['toolbar_icon_size']) 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: try: newloc = d.database_location diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index c499f3375e..4c7ee725d8 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -573,4 +573,6 @@ books_series_link feeds progress.setLabelText(_('Compacting database')) self.vacuum() progress.reset() + return len(books) +