aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/update.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-03-03 18:56:33 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-03-03 19:07:14 +0530
commitc4a508ab31f725545bb1faba10e21bc2a6416421 (patch)
treef33ea3f466c97e669e3723af249050f3d2362fae /yt_dlp/update.py
parent7815e5557231616b65995d2979b4ad701e2fc8c1 (diff)
downloadhypervideo-pre-c4a508ab31f725545bb1faba10e21bc2a6416421.tar.lz
hypervideo-pre-c4a508ab31f725545bb1faba10e21bc2a6416421.tar.xz
hypervideo-pre-c4a508ab31f725545bb1faba10e21bc2a6416421.zip
[update] Fix updater removing the executable bit on some UNIX distros
Closes #133
Diffstat (limited to 'yt_dlp/update.py')
-rw-r--r--yt_dlp/update.py22
1 files changed, 6 insertions, 16 deletions
diff --git a/yt_dlp/update.py b/yt_dlp/update.py
index 5ae4e5204..c773e2721 100644
--- a/yt_dlp/update.py
+++ b/yt_dlp/update.py
@@ -197,28 +197,18 @@ def update_self(to_screen, verbose, opener):
to_screen('Visit https://github.com/yt-dlp/yt-dlp/releases/latest')
return
- try:
- with open(filename + '.new', 'wb') as outf:
- outf.write(newcontent)
- except (IOError, OSError):
- if verbose:
- to_screen(encode_compat_str(traceback.format_exc()))
- to_screen('ERROR: unable to write the new version')
- return
-
expected_sum = get_sha256sum('zip', py_ver)
- if expected_sum and calc_sha256sum(filename + '.new') != expected_sum:
+ if expected_sum and hashlib.sha256(newcontent).hexdigest() != expected_sum:
to_screen('ERROR: unable to verify the new zip')
to_screen('Visit https://github.com/yt-dlp/yt-dlp/releases/latest')
- try:
- os.remove(filename + '.new')
- except OSError:
- to_screen('ERROR: unable to remove corrupt zip')
return
try:
- os.rename(filename + '.new', filename)
- except OSError:
+ with open(filename, 'wb') as outf:
+ outf.write(newcontent)
+ except (IOError, OSError):
+ if verbose:
+ to_screen(encode_compat_str(traceback.format_exc()))
to_screen('ERROR: unable to overwrite current version')
return