mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 09:01:43 +00:00
parent
8f84770acd
commit
a6125983ab
@ -9,7 +9,7 @@
|
|||||||
from zipimport import zipimporter
|
from zipimport import zipimporter
|
||||||
|
|
||||||
from .compat import functools # isort: split
|
from .compat import functools # isort: split
|
||||||
from .compat import compat_realpath
|
from .compat import compat_realpath, compat_shlex_quote
|
||||||
from .utils import (
|
from .utils import (
|
||||||
Popen,
|
Popen,
|
||||||
cached_method,
|
cached_method,
|
||||||
@ -229,24 +229,32 @@ def update(self):
|
|||||||
except OSError:
|
except OSError:
|
||||||
return self._report_permission_error(new_filename)
|
return self._report_permission_error(new_filename)
|
||||||
|
|
||||||
try:
|
|
||||||
if old_filename:
|
if old_filename:
|
||||||
|
try:
|
||||||
os.rename(self.filename, old_filename)
|
os.rename(self.filename, old_filename)
|
||||||
except OSError:
|
except OSError:
|
||||||
return self._report_error('Unable to move current version')
|
return self._report_error('Unable to move current version')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if old_filename:
|
|
||||||
os.rename(new_filename, self.filename)
|
os.rename(new_filename, self.filename)
|
||||||
except OSError:
|
except OSError:
|
||||||
self._report_error('Unable to overwrite current version')
|
self._report_error('Unable to overwrite current version')
|
||||||
return os.rename(old_filename, self.filename)
|
return os.rename(old_filename, self.filename)
|
||||||
|
|
||||||
if detect_variant() not in ('win32_exe', 'py2exe'):
|
if detect_variant() in ('win32_exe', 'py2exe'):
|
||||||
if old_filename:
|
|
||||||
os.remove(old_filename)
|
|
||||||
else:
|
|
||||||
atexit.register(Popen, f'ping 127.0.0.1 -n 5 -w 1000 & del /F "{old_filename}"',
|
atexit.register(Popen, f'ping 127.0.0.1 -n 5 -w 1000 & del /F "{old_filename}"',
|
||||||
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
elif old_filename:
|
||||||
|
try:
|
||||||
|
os.remove(old_filename)
|
||||||
|
except OSError:
|
||||||
|
self._report_error('Unable to remove the old version')
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.chmod(self.filename, 0o777)
|
||||||
|
except OSError:
|
||||||
|
return self._report_error(
|
||||||
|
f'Unable to set permissions. Run: sudo chmod a+rx {compat_shlex_quote(self.filename)}')
|
||||||
|
|
||||||
self.ydl.to_screen(f'Updated yt-dlp to version {self.new_version}')
|
self.ydl.to_screen(f'Updated yt-dlp to version {self.new_version}')
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user