From 6c4f3d85ab0a9140296e70760734f09ca0c8597e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 20 Nov 2022 11:02:08 +0530 Subject: [PATCH] Nook driver: Put files in NOOK/Books instead of NOOK/My Files on recent nook devices so they are all listed in one place in the NOOK UI. See #1990730 (books saved in wrong directory on nook 4e) --- src/calibre/devices/nook/driver.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/calibre/devices/nook/driver.py b/src/calibre/devices/nook/driver.py index fe430ce8d0..cdd5bfe9eb 100644 --- a/src/calibre/devices/nook/driver.py +++ b/src/calibre/devices/nook/driver.py @@ -6,7 +6,7 @@ __docformat__ = 'restructuredtext en' Device driver for Barns and Nobel's Nook ''' -import io, os, errno +import io, os from calibre import fsync, prints from calibre.constants import DEBUG @@ -105,14 +105,13 @@ class NOOK_COLOR(NOOK): if DEBUG: prints('Opened NOOK with product id:', product_id) if product_id >= 0xb: + self.EBOOK_DIR_MAIN = 'NOOK/Books' if product_id >= 0xd else 'NOOK/My Files' if DEBUG: - prints('Setting Nook upload directory to NOOK/My Files') - self.EBOOK_DIR_MAIN = 'NOOK/My Files' + prints(f'Setting Nook upload directory to {self.EBOOK_DIR_MAIN}') try: - os.makedirs(os.path.join(self._main_prefix, *self.EBOOK_DIR_MAIN.split('/'))) - except OSError as err: - if err.errno != errno.EEXIST: - self.EBOOK_DIR_MAIN = 'NOOK' + os.makedirs(os.path.join(self._main_prefix, *self.EBOOK_DIR_MAIN.split('/')), exist_ok=True) + except OSError: + self.EBOOK_DIR_MAIN = 'NOOK' def get_carda_ebook_dir(self, for_upload=False): if for_upload: