[YoutubeDL] prevent deleting the processed file if it's the same file

This commit is contained in:
Pierre Mdawar 2019-01-03 14:58:49 +02:00
parent 7e73a3e5c1
commit 4abc9041bf

View File

@ -2050,6 +2050,8 @@ class YoutubeDL(object):
self.report_error(e.msg) self.report_error(e.msg)
if files_to_delete and not self.params.get('keepvideo', False): if files_to_delete and not self.params.get('keepvideo', False):
for old_filename in files_to_delete: for old_filename in files_to_delete:
# don't delete the processed file if it happens to be in the same format
if old_filename != info['filepath']:
self.to_screen('Deleting original file %s (pass -k to keep)' % old_filename) self.to_screen('Deleting original file %s (pass -k to keep)' % old_filename)
try: try:
os.remove(encodeFilename(old_filename)) os.remove(encodeFilename(old_filename))