From 853181cc5872aab115f2cb1000c228a7abc0cb35 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Dec 2015 12:46:36 +0530 Subject: [PATCH] Dont popup an error if the directory chosen for a move does not exist --- src/calibre/gui2/dialogs/choose_library.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/dialogs/choose_library.py b/src/calibre/gui2/dialogs/choose_library.py index 27a9003c05..fc131dfd8e 100644 --- a/src/calibre/gui2/dialogs/choose_library.py +++ b/src/calibre/gui2/dialogs/choose_library.py @@ -5,7 +5,7 @@ __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import os +import os, errno from PyQt5.Qt import QDialog @@ -122,6 +122,12 @@ class ChooseLibrary(QDialog, Ui_Dialog): return error_dialog(self, _('No location'), _('No location selected'), show=True) loc = os.path.abspath(text) + if action == 'move': + try: + os.makedirs(loc) + except EnvironmentError as e: + if e.errno != errno.EEXIST: + raise if not loc or not os.path.exists(loc) or not os.path.isdir(loc): return error_dialog(self, _('Bad location'), _('%s is not an existing folder')%loc, show=True)