Skip to content
Snippets Groups Projects
Commit b884908b authored by jan.bednarik's avatar jan.bednarik
Browse files

shared: Jekyll import skip save images on dry run

parent 7ba7586c
No related branches found
No related tags found
2 merge requests!452shared: Jekyll import skip save images on dry run,!451shared: Jekyll import skip save images on dry run
Pipeline #7489 passed
...@@ -120,6 +120,7 @@ def get_or_create_image( ...@@ -120,6 +120,7 @@ def get_or_create_image(
try: try:
file = ImageFile(open(os.path.join(path, file_path), "rb"), name=file_path) file = ImageFile(open(os.path.join(path, file_path), "rb"), name=file_path)
image = Image(title=file_path, file=file, collection=collection) image = Image(title=file_path, file=file, collection=collection)
if not image_params["dry_run"]:
image.save() image.save()
return image, "" return image, ""
except FileNotFoundError: except FileNotFoundError:
...@@ -131,6 +132,7 @@ def get_or_create_image( ...@@ -131,6 +132,7 @@ def get_or_create_image(
name=file_path, name=file_path,
) )
image = Image(title=file_path, file=file, collection=collection) image = Image(title=file_path, file=file, collection=collection)
if not image_params["dry_run"]:
image.save() image.save()
return image, "" return image, ""
except FileNotFoundError: except FileNotFoundError:
...@@ -142,6 +144,7 @@ def get_or_create_image( ...@@ -142,6 +144,7 @@ def get_or_create_image(
name=file_path, name=file_path,
) )
image = Image(title=file_path, file=file, collection=collection) image = Image(title=file_path, file=file, collection=collection)
if not image_params["dry_run"]:
image.save() image.save()
return image, "" return image, ""
except FileNotFoundError: except FileNotFoundError:
...@@ -183,6 +186,7 @@ def get_or_create_image( ...@@ -183,6 +186,7 @@ def get_or_create_image(
image = Image(title=file_path, file=file, collection=collection) image = Image(title=file_path, file=file, collection=collection)
try: try:
if not image_params["dry_run"]:
image.save() image.save()
except Exception as e: except Exception as e:
msg = "Nelze uložit obrázek" msg = "Nelze uložit obrázek"
...@@ -320,6 +324,7 @@ class JekyllArticleImporter: ...@@ -320,6 +324,7 @@ class JekyllArticleImporter:
image_params["path"] = self.path image_params["path"] = self.path
image_params["collection"] = self.collection image_params["collection"] = self.collection
image_params["repo_name"] = self.repo_name image_params["repo_name"] = self.repo_name
image_params["dry_run"] = self.dry_run
def create_redirects(self, article, match): def create_redirects(self, article, match):
y = match.group(1) y = match.group(1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment