Skip to content

Commit

Permalink
Fix update manager linux permission issues
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaScheller committed Oct 28, 2023
1 parent da29dfd commit 9a28961
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/update_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@
QT_ROLE_RELEASE = QtCore.Qt.UserRole + 1001


class ZipFileWithPermissions(zipfile.ZipFile):
""" Custom ZipFile class handling file permissions.
See https://stackoverflow.com/questions/39296101/python-zipfile-removes-execute-permissions-from-binaries
"""
def _extract_member(self, member, target_path, pwd):
if not isinstance(member, zipfile.ZipInfo):
member = self.getinfo(member)
target_path = super()._extract_member(member, target_path, pwd)
attr = member.external_attr >> 16
if attr != 0:
os.chmod(target_path, attr)
return target_path


class UpdateManagerUI(QtWidgets.QDialog):
def __init__(self, parent):
super(UpdateManagerUI, self).__init__(parent)
Expand Down Expand Up @@ -425,7 +439,7 @@ def uncompress_file(self, file_path, compression_type="zip"):
)
if not os.path.exists(dir_path):
os.makedirs(dir_path)
with zipfile.ZipFile(file_path, "r", zipfile.ZIP_DEFLATED) as archive:
with ZipFileWithPermissions(file_path, "r", zipfile.ZIP_DEFLATED) as archive:
archive.extractall(dir_path)
os.remove(file_path)
else:
Expand Down

0 comments on commit 9a28961

Please sign in to comment.