From daa9f9703f77798278e5c4f7a4d33ea06145a833 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 17 Aug 2012 18:00:55 +0530 Subject: [PATCH] Fix for renaming duplicate lossy folders if the lossless folder exists --- headphones/postprocessor.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index f6fde523..27581b93 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -414,14 +414,17 @@ def moveFiles(albumpath, release, tracks): if make_lossless_folder: # Only rename the folder if they use the album name, otherwise merge into existing folder if os.path.exists(lossless_destination_path) and 'album' in last_folder.lower(): + + temp_folder = folder + i = 1 while True: - newfolder = folder + '[%i]' % i + newfolder = temp_folder + '[%i]' % i lossless_destination_path = os.path.normpath(os.path.join(headphones.LOSSLESS_DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING) if os.path.exists(lossless_destination_path): i += 1 else: - folder = newfolder + temp_folder = newfolder break if not os.path.exists(lossless_destination_path): @@ -434,14 +437,17 @@ def moveFiles(albumpath, release, tracks): if make_lossy_folder: if os.path.exists(lossy_destination_path) and 'album' in last_folder.lower(): + + temp_folder = folder + i = 1 while True: - newfolder = folder + '[%i]' % i + newfolder = temp_folder + '[%i]' % i lossy_destination_path = os.path.normpath(os.path.join(headphones.DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING) if os.path.exists(lossy_destination_path): i += 1 else: - folder = newfolder + temp_folder = newfolder break if not os.path.exists(lossy_destination_path):