Skip to content

Commit

Permalink
Merge pull request avocado-framework#5753 from faker-king/master
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Richter <[email protected]>
  • Loading branch information
richtja authored Sep 5, 2023
2 parents a7bddf1 + 96c5bb8 commit 4bf7543
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions avocado/utils/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ def _update_zip_extra_attrs(self, dst_dir):
return
attr = info.external_attr >> 16
if attr & stat.S_IFLNK == stat.S_IFLNK:
dst = os.path.join(dst_dir, path)
if not os.path.islink(dst):
# Link created as an ordinary file containing the dst path
with open(dst, "r") as dst_path: # pylint: disable=W1514
Expand All @@ -289,12 +288,19 @@ def _update_zip_extra_attrs(self, dst_dir):
# Link is already there and could be outdated. Let's read
# the original destination from the zip file.
src = self._engine.read(path)
os.remove(dst)
os.symlink(src, dst)
try:
os.remove(dst)
os.symlink(src, dst)
except Exception as e:
LOG.warning(f"Failed to update symlink '{dst}': {str(e)}")
continue
continue # Don't override any other attributes on links
mode = attr & 511 # Mask only permissions
if mode and mode != 436: # If mode is stored and is not default
os.chmod(dst, mode)
try:
os.chmod(dst, mode)
except Exception as e:
LOG.warning(f"Failed to update permissions for '{dst}': {str(e)}")

def close(self):
"""
Expand Down

0 comments on commit 4bf7543

Please sign in to comment.