aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/postprocessor/embedthumbnail.py
diff options
context:
space:
mode:
authorPaul Wrubel <pwrubel7@gmail.com>2021-08-26 21:27:20 -0500
committerGitHub <noreply@github.com>2021-08-27 07:57:20 +0530
commitd75201a873a413d73f12748e5710f000e9f727da (patch)
tree6d60de6dbbf3892dc2e5d49c6c78e4e0123174fd /yt_dlp/postprocessor/embedthumbnail.py
parent691d5823d6ff72b813eb34ede8009b70bebd73da (diff)
downloadhypervideo-pre-d75201a873a413d73f12748e5710f000e9f727da.tar.lz
hypervideo-pre-d75201a873a413d73f12748e5710f000e9f727da.tar.xz
hypervideo-pre-d75201a873a413d73f12748e5710f000e9f727da.zip
Use `os.replace` where applicable (#793)
When using ```py os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) ``` the `os.remove` need not be atomic and so can be executed arbitrarily compared to the immediately following rename call. It is better to use `os.replace` instead Authored by: paulwrubel
Diffstat (limited to 'yt_dlp/postprocessor/embedthumbnail.py')
-rw-r--r--yt_dlp/postprocessor/embedthumbnail.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/yt_dlp/postprocessor/embedthumbnail.py b/yt_dlp/postprocessor/embedthumbnail.py
index 7008f4d4d..3139a6338 100644
--- a/yt_dlp/postprocessor/embedthumbnail.py
+++ b/yt_dlp/postprocessor/embedthumbnail.py
@@ -222,8 +222,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
raise EmbedThumbnailPPError('Supported filetypes for thumbnail embedding are: mp3, mkv/mka, ogg/opus/flac, m4a/mp4/mov')
if success and temp_filename != filename:
- os.remove(encodeFilename(filename))
- os.rename(encodeFilename(temp_filename), encodeFilename(filename))
+ os.replace(temp_filename, filename)
self.try_utime(filename, mtime, mtime)