Skip to content

Commit

Permalink
Merge pull request #85 from sclorg/fix_traceback_missing_source
Browse files Browse the repository at this point in the history
Fix for 'src_path_content' in upstream does not exist
  • Loading branch information
phracek authored Nov 13, 2024
2 parents a0cdf9b + 92964fd commit 4287e31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
dockerfiles: ./Dockerfile.generator
image: cwt-generator
tags: latest 1 ${{ github.sha }} 1.5.9
tags: latest 1 ${{ github.sha }} 1.5.10

- name: Push cwt-generator image to Quay.io
id: push-to-quay
Expand Down
13 changes: 11 additions & 2 deletions container_workflow_tool/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@ def handle_dangling_symlinks(self, src_parent, dest_parent):
src_path_content = os.path.join(src_parent, dest_path_rel)
self.logger.debug(f"unlink {dest_file}")
os.unlink(dest_file)
src_full = os.path.join(os.path.dirname(src_path_content),
os.readlink(src_path_content))
# Catch exception in case of 'os.readlink(src_path_content)' does not exist.
# This code is used during update upstream -> downstream.
# The row `os.unlink` above delete dest_file in case we delete it in upstream PR
# But `os.readlink(src_path_content)` fail with traceback because of file does not exist
try:
src_full = os.path.join(os.path.dirname(src_path_content),
os.readlink(src_path_content))
except FileNotFoundError:
self.logger.debug(f"Source file {src_path_content} does not exist."
f"It was deleted by upstream PR")
continue
if os.path.isdir(src_full):
# In this case, when the source directory includes another symlinks outside
# of this directory, those wouldn't be fixed, so let's run the same function
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_dir(system_path=None, virtual_path=None):

setup(
name='container-workflow-tool',
version="1.5.9",
version="1.5.10",
description='A python3 tool to make rebuilding images easier by automating several steps of the process.',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 4287e31

Please sign in to comment.