From 6440c45ff3c3209593c0f39af075e71e4ca0299a Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sun, 14 Aug 2022 22:51:38 +0530 Subject: [PATCH] [update] Copy bitmask from old binary Improves a6125983ab4434fc4079f575a4bf22042411ea5e Authored by: Lesmiscore --- yt_dlp/update.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yt_dlp/update.py b/yt_dlp/update.py index a5cd11150..fc96f2985 100644 --- a/yt_dlp/update.py +++ b/yt_dlp/update.py @@ -230,6 +230,7 @@ class Updater: return self._report_permission_error(new_filename) if old_filename: + mask = os.stat(self.filename).st_mode try: os.rename(self.filename, old_filename) except OSError: @@ -251,7 +252,7 @@ class Updater: self._report_error('Unable to remove the old version') try: - os.chmod(self.filename, 0o777) + os.chmod(self.filename, mask) except OSError: return self._report_error( f'Unable to set permissions. Run: sudo chmod a+rx {compat_shlex_quote(self.filename)}')