about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2020-02-08 19:38:36 +0700
committerSergey M․ <dstftw@gmail.com>2020-02-08 19:46:58 +0700
commitbfe2b8cf2ac57c6b66def2d5e0fc3fc424c78d75 (patch)
treed46b71fc3b8561e5b9612a35be556ccf8c634cdb
parent82fea5b42eadc4ac2d3f4f688613f140967e92b7 (diff)
downloadyoutube-dl-bfe2b8cf2ac57c6b66def2d5e0fc3fc424c78d75.tar.gz
youtube-dl-bfe2b8cf2ac57c6b66def2d5e0fc3fc424c78d75.tar.xz
youtube-dl-bfe2b8cf2ac57c6b66def2d5e0fc3fc424c78d75.zip
[update] Fix updating via symlinks (closes #23991)
-rw-r--r--youtube_dl/compat.py1
-rw-r--r--youtube_dl/update.py5
2 files changed, 5 insertions, 1 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index 062b338d7..d1b86bd13 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -3009,6 +3009,7 @@ __all__ = [
     'compat_os_name',
     'compat_parse_qs',
     'compat_print',
+    'compat_realpath',
     'compat_setenv',
     'compat_shlex_quote',
     'compat_shlex_split',
diff --git a/youtube_dl/update.py b/youtube_dl/update.py
index 002ea7f33..84c964617 100644
--- a/youtube_dl/update.py
+++ b/youtube_dl/update.py
@@ -9,6 +9,7 @@ import subprocess
 import sys
 from zipimport import zipimporter
 
+from .compat import compat_realpath
 from .utils import encode_compat_str
 
 from .version import __version__
@@ -84,7 +85,9 @@ def update_self(to_screen, verbose, opener):
     print_notes(to_screen, versions_info['versions'])
 
     # sys.executable is set to the full pathname of the exe-file for py2exe
-    filename = sys.executable if hasattr(sys, 'frozen') else sys.argv[0]
+    # though symlinks are not followed so that we need to do this manually
+    # with help of realpath
+    filename = compat_realpath(sys.executable if hasattr(sys, 'frozen') else sys.argv[0])
 
     if not os.access(filename, os.W_OK):
         to_screen('ERROR: no write permissions on %s' % filename)