X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/79d770e03bde9d600ec6effdcc9c15487ff23897..b9dc6590aa12ae1b04e11dbb57684c5630c1e3bd:/src/catalogue/models/book.py?ds=sidebyside 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)