X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c3fc1fa1087b5c12e287f6a7194d7a98fc27817e..bc0bb8065feb8d56bc6b1fee112f22c701c303f2:/src/catalogue/models/book.py?ds=sidebyside diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index 6e66f2ee4..a4017fbb9 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -247,6 +247,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) ilustr_elements = list(self.wldocument().edoc.findall('//ilustr')) if ilustr_elements: makedirs(gallery_path)