diff --git a/shared/jekyll_import.py b/shared/jekyll_import.py index b092f214ad51a976e03a8ff6ff60d923cbc2f957..a471ad35793b586e695f48bead7ab618b0ab98b7 100644 --- a/shared/jekyll_import.py +++ b/shared/jekyll_import.py @@ -120,7 +120,8 @@ def get_or_create_image( try: file = ImageFile(open(os.path.join(path, file_path), "rb"), name=file_path) image = Image(title=file_path, file=file, collection=collection) - image.save() + if not image_params["dry_run"]: + image.save() return image, "" except FileNotFoundError: pass # cesta pomocí file_path neexisuje, jdeme dál @@ -131,7 +132,8 @@ def get_or_create_image( name=file_path, ) image = Image(title=file_path, file=file, collection=collection) - image.save() + if not image_params["dry_run"]: + image.save() return image, "" except FileNotFoundError: pass # cesta s vložením "assets/img" před file_path neexisuje, jdeme dál @@ -142,7 +144,8 @@ def get_or_create_image( name=file_path, ) image = Image(title=file_path, file=file, collection=collection) - image.save() + if not image_params["dry_run"]: + image.save() return image, "" except FileNotFoundError: pass @@ -183,7 +186,8 @@ def get_or_create_image( image = Image(title=file_path, file=file, collection=collection) try: - image.save() + if not image_params["dry_run"]: + image.save() except Exception as e: msg = "Nelze uložit obrázek" logger.warning(msg, extra={"exc": e}) @@ -320,6 +324,7 @@ class JekyllArticleImporter: image_params["path"] = self.path image_params["collection"] = self.collection image_params["repo_name"] = self.repo_name + image_params["dry_run"] = self.dry_run def create_redirects(self, article, match): y = match.group(1)