X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/79d770e03bde9d600ec6effdcc9c15487ff23897..4d9f6719c754615261fc5c63d5a7081e598ed711:/src/catalogue/models/book.py diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index f1501d02c..3811bbac1 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -251,9 +251,10 @@ class Book(models.Model): def download_pictures(self, remote_gallery_url): gallery_path = self.gallery_path() # delete previous files, so we don't include old files in ebooks - for filename in os.listdir(gallery_path): - file_path = os.path.join(gallery_path, filename) - os.unlink(file_path) + if os.path.isdir(gallery_path): + for filename in os.listdir(gallery_path): + file_path = os.path.join(gallery_path, filename) + os.unlink(file_path) ilustr_elements = list(self.wldocument().edoc.findall('//ilustr')) if ilustr_elements: makedirs(gallery_path)