[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,11 +2050,13 @@ class YoutubeDL(object):
self.report_error(e.msg)
if files_to_delete and not self.params.get('keepvideo', False):
for old_filename in files_to_delete:
self.to_screen('Deleting original file %s (pass -k to keep)' % old_filename)
try:
os.remove(encodeFilename(old_filename))
except (IOError, OSError):
self.report_warning('Unable to remove downloaded original file')
# 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)
try:
os.remove(encodeFilename(old_filename))
except (IOError, OSError):
self.report_warning('Unable to remove downloaded original file')
def _make_archive_id(self, info_dict):
# Future-proof against any change in case