From f76440fd0edbfa9318aeb95bd8b1ff8aa9122737 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 3 Jun 2024 22:21:53 +0530 Subject: [PATCH] Ignore stray files created by third party processes in the notes restore dir --- src/calibre/db/notes/connect.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/db/notes/connect.py b/src/calibre/db/notes/connect.py index c0f0a68b72..64bfd5ffb7 100644 --- a/src/calibre/db/notes/connect.py +++ b/src/calibre/db/notes/connect.py @@ -468,7 +468,11 @@ class Notes: resources = {} errors = [] for subdir in os.listdir(make_long_path_useable(self.resources_dir)): - for rf in os.listdir(make_long_path_useable(os.path.join(self.resources_dir, subdir))): + try: + subitems = os.listdir(make_long_path_useable(os.path.join(self.resources_dir, subdir))) + except NotADirectoryError: + continue + for rf in subitems: if not rf.endswith(METADATA_EXT): name_path = os.path.join(self.resources_dir, subdir, rf + METADATA_EXT) name = 'unnamed'