mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
The GUI no longer tries to migrate the old library1.db automatically. Use calibre-debug --migrate for this.
This commit is contained in:
parent
f5dd06b9c2
commit
6b1d2571c1
@ -309,18 +309,7 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
self.library_path = dir
|
self.library_path = dir
|
||||||
db = LibraryDatabase2(self.library_path)
|
db = LibraryDatabase2(self.library_path)
|
||||||
self.library_view.set_database(db)
|
self.library_view.set_database(db)
|
||||||
if self.olddb is not None:
|
prefs['library_path'] = self.library_path
|
||||||
pd = QProgressDialog('', '', 0, 100, self)
|
|
||||||
pd.setWindowModality(Qt.ApplicationModal)
|
|
||||||
pd.setCancelButton(None)
|
|
||||||
pd.setWindowTitle(_('Migrating database'))
|
|
||||||
pd.show()
|
|
||||||
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(*dynamic.get('sort_column', ('timestamp', Qt.DescendingOrder)))
|
self.library_view.sortByColumn(*dynamic.get('sort_column', ('timestamp', Qt.DescendingOrder)))
|
||||||
if not self.library_view.restore_column_widths():
|
if not self.library_view.restore_column_widths():
|
||||||
self.library_view.resizeColumnsToContents()
|
self.library_view.resizeColumnsToContents()
|
||||||
@ -1392,39 +1381,14 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
def initialize_database(self):
|
def initialize_database(self):
|
||||||
self.library_path = prefs['library_path']
|
self.library_path = prefs['library_path']
|
||||||
self.olddb = None
|
|
||||||
if self.library_path is None: # Need to migrate to new database layout
|
if self.library_path is None: # Need to migrate to new database layout
|
||||||
QMessageBox.information(self, 'Database format changed',
|
|
||||||
'''\
|
|
||||||
<p>calibre's book storage format has changed. Instead of storing book files in a database, the
|
|
||||||
files are now stored in a folder on your filesystem. You will now be asked to choose the folder
|
|
||||||
in which you want to store your books files. Any existing books will be automatically migrated.
|
|
||||||
''')
|
|
||||||
self.database_path = prefs['database_path']
|
|
||||||
if not os.access(os.path.dirname(self.database_path), os.W_OK):
|
|
||||||
error_dialog(self, _('Database does not exist'),
|
|
||||||
_('The directory in which the database should be: %s no longer exists. Please choose a new database location.')%self.database_path).exec_()
|
|
||||||
self.database_path = choose_dir(self, 'database path dialog',
|
|
||||||
_('Choose new location for database'))
|
|
||||||
if not self.database_path:
|
|
||||||
self.database_path = os.path.expanduser('~').decode(sys.getfilesystemencoding())
|
|
||||||
if not os.path.exists(self.database_path):
|
|
||||||
os.makedirs(self.database_path)
|
|
||||||
self.database_path = os.path.join(self.database_path, 'library1.db')
|
|
||||||
prefs['database_path'] = self.database_path
|
|
||||||
home = os.path.dirname(self.database_path)
|
|
||||||
if not os.path.exists(home):
|
|
||||||
home = os.getcwd()
|
|
||||||
dir = unicode(QFileDialog.getExistingDirectory(self,
|
dir = unicode(QFileDialog.getExistingDirectory(self,
|
||||||
_('Choose a location for your ebook library.'), home))
|
_('Choose a location for your ebook library.'), os.getcwd()))
|
||||||
if not dir:
|
if not dir:
|
||||||
dir = os.path.dirname(self.database_path)
|
dir = os.path.expanduser('~/Library')
|
||||||
self.library_path = os.path.abspath(dir)
|
self.library_path = os.path.abspath(dir)
|
||||||
try:
|
if not os.path.exists(self.library_path):
|
||||||
self.olddb = LibraryDatabase(self.database_path)
|
os.makedirs(self.library_path)
|
||||||
except:
|
|
||||||
traceback.print_exc()
|
|
||||||
self.olddb = None
|
|
||||||
|
|
||||||
|
|
||||||
def read_settings(self):
|
def read_settings(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user