Make new_file variable ony after checking if old file exists

This commit is contained in:
Sambhav Kothari
2016-12-29 17:16:33 +05:30
parent 91e5bdbd6c
commit 31d3fcff78

View File

@@ -357,12 +357,12 @@ class File(QtCore.QObject, Item):
pattern_regex = re.compile(fnmatch.translate(pattern), re.IGNORECASE)
for old_file in os.listdir(old_path):
if pattern_regex.match(old_file):
new_file = os.path.join(new_path, old_file)
old_file = os.path.join(old_path, old_file)
# FIXME we shouldn't do this from a thread!
if self.tagger.files.get(decode_filename(old_file)):
log.debug("File loaded in the tagger, not moving %r", old_file)
continue
new_file = os.path.join(new_path, old_file)
log.debug("Moving %r to %r", old_file, new_file)
shutil.move(old_file, new_file)