diff --git a/AUTHORS b/AUTHORS index 2430eed..b17041d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,6 +2,7 @@ Sigal is written and maintained by Simon Conseil and contributors (in alphabetical order): - Abdul Qabiz +- Alexandre Chataignon (@xouillet) - Alexey Bazhin - Andreas Sieferlinger - Antoine Pitrou diff --git a/sigal/gallery.py b/sigal/gallery.py index e6f514d..5f47065 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -102,15 +102,17 @@ class Media(UnicodeMixin): return self.filename orig_path = join(s['destination'], self.path, s['orig_dir']) check_or_create_dir(orig_path) - copy(self.src_path, join(orig_path, self.src_filename), - symlink=s['orig_link']) + big_path = join(orig_path, self.src_filename) + if not isfile(big_path): + copy(self.src_path, big_path, + symlink=s['orig_link']) return url_from_path(join(s['orig_dir'], self.src_filename)) @property def thumbnail(self): """Path to the thumbnail image (relative to the album directory).""" - if not os.path.isfile(self.thumb_path): + if not isfile(self.thumb_path): # if thumbnail is missing (if settings['make_thumbs'] is False) if self.type == 'image': generator = image.generate_thumbnail @@ -476,7 +478,7 @@ class Album(UnicodeMixin): """ return any(image.has_location() for image in self.images) - @property + @cached_property def zip(self): """Make a ZIP archive with all media files and return its path. @@ -489,6 +491,10 @@ class Album(UnicodeMixin): if zip_gallery and len(self) > 0: zip_gallery = zip_gallery.format(album=self) archive_path = join(self.dst_path, zip_gallery) + if self.settings.get('zip_skip_if_exists', False) and isfile(archive_path): + self.logger.debug("Archive %s already created, passing", archive_path) + return zip_gallery + archive = zipfile.ZipFile(archive_path, 'w', allowZip64=True) attr = ('src_path' if self.settings['zip_media_format'] == 'orig' else 'dst_path') diff --git a/sigal/templates/sigal.conf.py b/sigal/templates/sigal.conf.py index 5b52a12..b9f679a 100644 --- a/sigal/templates/sigal.conf.py +++ b/sigal/templates/sigal.conf.py @@ -188,6 +188,7 @@ ignore_files = [] # contain all resized or original files (depending on `zip_media_format`). # zip_gallery = False # False or 'archive.zip' # zip_media_format = 'resized' # 'resized' or 'orig' +# zip_skip_if_exists = False # Skip archive generation if archive is already present. Warning: new photos in an album won't be added to archive # Specify a different locale. If set to '', the default locale is used. # locale = ''