diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 2df1e1bc4b..50745ddd84 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -127,7 +127,10 @@ def get_library_path(gui_runner): if library_path is None: # Need to migrate to new database layout base = os.path.expanduser('~') if iswindows: - base = winutil.special_folder_path(winutil.CSIDL_PERSONAL) + try: + base = winutil.special_folder_path(winutil.CSIDL_PERSONAL) + except ValueError: + base = None if not base or not os.path.exists(base): from PyQt5.Qt import QDir base = unicode(QDir.homePath()).replace('/', os.sep) diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index 010dd2bc1b..5635428c23 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -12,7 +12,7 @@ from contextlib import closing from PyQt5.Qt import (QWizard, QWizardPage, QPixmap, Qt, QAbstractListModel, - QItemSelectionModel, QObject, QTimer, pyqtSignal, QItemSelection) + QItemSelectionModel, QObject, QTimer, pyqtSignal, QItemSelection, QDir) from calibre import __appname__, patheq from calibre.library.move import MoveLibrary from calibre.constants import (filesystem_encoding, iswindows, plugins, @@ -805,7 +805,10 @@ class LibraryPage(QWizardPage, LibraryUI): fname = _('Calibre Library') base = os.path.expanduser(u'~') if iswindows: - x = winutil.special_folder_path(winutil.CSIDL_PERSONAL) + try: + x = winutil.special_folder_path(winutil.CSIDL_PERSONAL) + except ValueError: + x = QDir.homePath().replace('/', os.sep) if x and os.access(x, os.W_OK): base = x @@ -837,8 +840,7 @@ class LibraryPage(QWizardPage, LibraryUI): newloc = unicode(self.location.text()) try: dln = self.default_library_name - if (dln and os.path.exists(dln) and not os.listdir(dln) and newloc - != dln): + if (dln and os.path.exists(dln) and not os.listdir(dln) and newloc != dln): os.rmdir(dln) except: pass