Fix renaming files when encoder is not present

This commit is contained in:
Ritiek Malhotra
2019-01-13 18:19:06 +05:30
parent 94500e31a3
commit 54d3336aa2

View File

@@ -83,7 +83,12 @@ class Converter:
os.rename(self.output_file, self.input_file)
log.debug(command)
code = subprocess.call(command)
try:
code = subprocess.call(command)
except FileNotFoundError:
if self.rename_to_temp:
os.rename(self.input_file, self.output_file)
raise
if self.delete_original:
log.debug('Removing original file: "{}"'.format(self.input_file))
@@ -134,7 +139,12 @@ class Converter:
os.rename(self.output_file, self.input_file)
log.debug(command)
code = subprocess.call(command)
try:
code = subprocess.call(command)
except FileNotFoundError:
if self.rename_to_temp:
os.rename(self.input_file, self.output_file)
raise
if self.delete_original:
log.debug('Removing original file: "{}"'.format(self.input_file))