-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Output Problem(EMBEDDING YOUTUBE-DL) #28488
Comments
In windows, the exe cannot update itself directly. So youtube-dl opens a new process with a batch script which does the actual updating. The The relevant code: bat = os.path.join(directory, 'youtube-dl-updater.bat')
with io.open(bat, 'w') as batfile:
batfile.write('''
@echo off
echo Waiting for file handle to be closed ...
ping 127.0.0.1 -n 5 -w 1000 > NUL
move /Y "%s.new" "%s" > NUL
echo Updated youtube-dl to version %s.
start /b "" cmd /c del "%%~f0"&exit /b"
\n''' % (exe, exe, version_id))
subprocess.Popen([bat]) # Continues to run in the background You can either set a fixed sleep of ~10sec, or will need to watch if the subprocess has exited |
That's what I did, thanks for the info though |
Closes: #335, ytdl-org/youtube-dl#28488, ytdl-org/youtube-dl#5810, ytdl-org/youtube-dl#5994 In windows, a running executable cannot be replaced. So, the old updater worked by launching a batch script and then exiting, so that the batch script can replace the executable. However, this caused the above-mentioned issues. The new method takes advantage of the fact that while the executable cannot be replaced or deleted, it can still be renamed. The current update process on windows is as follows: 1. Delete `yt-dlp.exe.old` if it exists 2. Download the new version as `yt-dlp.exe.new` 3. Rename the running exe to `yt-dlp.exe.old` 4. Rename `yt-dlp.exe.new` to `yt-dlp.exe` 5. Open a shell that deletes `yt-dlp.exe.old` and terminate While we still use a subprocess, the actual update is already done before the app terminates and the batch script does not print anything to stdout/stderr. So this solves all the above issues
Closes: yt-dlp#335, ytdl-org/youtube-dl#28488, ytdl-org/youtube-dl#5810, ytdl-org/youtube-dl#5994 In windows, a running executable cannot be replaced. So, the old updater worked by launching a batch script and then exiting, so that the batch script can replace the executable. However, this caused the above-mentioned issues. The new method takes advantage of the fact that while the executable cannot be replaced or deleted, it can still be renamed. The current update process on windows is as follows: 1. Delete `yt-dlp.exe.old` if it exists 2. Download the new version as `yt-dlp.exe.new` 3. Rename the running exe to `yt-dlp.exe.old` 4. Rename `yt-dlp.exe.new` to `yt-dlp.exe` 5. Open a shell that deletes `yt-dlp.exe.old` and terminate While we still use a subprocess, the actual update is already done before the app terminates and the batch script does not print anything to stdout/stderr. So this solves all the above issues
I can't parse the output that tells that the update has succeeded.(run from Qt QProcess)
When I run the update(-U), all the output I catch is this:
But with only that it can't be said for sure when the update has been completed since that info comes later:
There's no way to know how long after.
Is there a solution for this?
The text was updated successfully, but these errors were encountered: