From 8e1aa18b8f96dbb6c96f41d510506359dc392c8b Mon Sep 17 00:00:00 2001 From: Andrzej Ciarkowski Date: Fri, 5 Feb 2016 14:54:12 +0100 Subject: [PATCH] postprocessor.py: Delete the proper temp dir after postprocessing Fix for the bug leaving spurious temp dirs after each album processing, due to headphones trying to rmtree the subdirectory instead of the temp dir itself. --- headphones/postprocessor.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 432ab796..9242ec09 100755 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -314,12 +314,13 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, new_folder = None # Check to see if we're preserving the torrent dir if (headphones.CONFIG.KEEP_TORRENT_FILES and Kind == "torrent" and 'headphones-modified' not in albumpath) or headphones.CONFIG.KEEP_ORIGINAL_FOLDER or keep_original_folder: - new_folder = os.path.join(tempfile.mkdtemp(prefix="headphones_"), "headphones") - logger.info("Copying files to " + new_folder.decode(headphones.SYS_ENCODING, 'replace') + " subfolder to preserve downloaded files for seeding") + new_folder = tempfile.mkdtemp(prefix="headphones_") + subdir = os.path.join(new_folder, "headphones") + logger.info("Copying files to " + subdir.decode(headphones.SYS_ENCODING, 'replace') + " subfolder to preserve downloaded files for seeding") try: - shutil.copytree(albumpath, new_folder) + shutil.copytree(albumpath, subdir) # Update the album path with the new location - albumpath = new_folder + albumpath = subdir except Exception as e: logger.warn("Cannot copy/move files to temp folder: " + new_folder.decode(headphones.SYS_ENCODING, 'replace') + ". Not continuing. Error: " + str(e)) shutil.rmtree(new_folder)