diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-08-14 21:13:02 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-08-15 00:28:49 +0530 |
commit | f775c83110ac9e9166e080b58a08ccc680c41338 (patch) | |
tree | 6cc12e1c21e6c137bfa60cc0033a782911190181 | |
parent | b714b41f813543822726807c261fcdcc9f2a0015 (diff) | |
download | hypervideo-pre-f775c83110ac9e9166e080b58a08ccc680c41338.tar.lz hypervideo-pre-f775c83110ac9e9166e080b58a08ccc680c41338.tar.xz hypervideo-pre-f775c83110ac9e9166e080b58a08ccc680c41338.zip |
Fix `--force-overwrites` when using `-k`
For formats that need merge, the `.fxxx` files are not removed before
downloading the corresponding `.part` files. This causes the rename to fail
-rw-r--r-- | yt_dlp/downloader/common.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/yt_dlp/downloader/common.py b/yt_dlp/downloader/common.py index 3846a7ee5..f5f6393a6 100644 --- a/yt_dlp/downloader/common.py +++ b/yt_dlp/downloader/common.py @@ -204,9 +204,12 @@ class FileDownloader(object): return filename + '.ytdl' def try_rename(self, old_filename, new_filename): + if old_filename == new_filename: + return try: - if old_filename == new_filename: - return + if self.params.get('overwrites', False): + if os.path.isfile(encodeFilename(new_filename)): + os.remove(encodeFilename(new_filename)) os.rename(encodeFilename(old_filename), encodeFilename(new_filename)) except (IOError, OSError) as err: self.report_error('unable to rename file: %s' % error_to_compat_str(err)) |