mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 06:01:24 +01:00
[update] Fix updater removing the executable bit on some UNIX distros
Closes #133
This commit is contained in:
parent
7815e55572
commit
c4a508ab31
@ -197,28 +197,18 @@ def update_self(to_screen, verbose, opener):
|
|||||||
to_screen('Visit https://github.com/yt-dlp/yt-dlp/releases/latest')
|
to_screen('Visit https://github.com/yt-dlp/yt-dlp/releases/latest')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
expected_sum = get_sha256sum('zip', py_ver)
|
||||||
|
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')
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(filename + '.new', 'wb') as outf:
|
with open(filename, 'wb') as outf:
|
||||||
outf.write(newcontent)
|
outf.write(newcontent)
|
||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
if verbose:
|
if verbose:
|
||||||
to_screen(encode_compat_str(traceback.format_exc()))
|
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:
|
|
||||||
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:
|
|
||||||
to_screen('ERROR: unable to overwrite current version')
|
to_screen('ERROR: unable to overwrite current version')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user