mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-08-09 05:29:41 +00:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user