From eec6ed3b11d22b480bd43dd8bc8e549ae05a4b39 Mon Sep 17 00:00:00 2001 From: echel0n Date: Fri, 25 Apr 2014 03:02:38 -0700 Subject: [PATCH] Fixed issue for wrong destination set for cleaning in TorrentToMedia. Checks for directory exists before attempting to clean it incase processor has already cleaned and removed it. --- TorrentToMedia.py | 2 +- nzbtomedia/nzbToMediaUtil.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 3176fa90..cbd9ae98 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -202,7 +202,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, nzbtomedia.remove_torrent(clientAgent, inputHash, inputID, inputName) # cleanup our processing folders of any misc unwanted files and empty directories - nzbtomedia.cleanDir(inputDirectory, sectionName, inputCategory) + nzbtomedia.cleanDir(outputDestination, sectionName, inputCategory) return result diff --git a/nzbtomedia/nzbToMediaUtil.py b/nzbtomedia/nzbToMediaUtil.py index 9258984d..daba27e9 100644 --- a/nzbtomedia/nzbToMediaUtil.py +++ b/nzbtomedia/nzbToMediaUtil.py @@ -457,7 +457,10 @@ def rmDir(dirName): logger.error("Unable to delete folder %s" % (dirName)) def cleanDir(path, section, subsection): - logger.info('Cleaning directory:%s ...' % (path), 'CLEANDIRS') + if not os.path.exists(path): + logger.info('Directory %s has been processed and removed ...' % (path), 'CLEANDIR') + return + try: minSize = int(nzbtomedia.CFG[section][subsection]['minSize']) except:minSize = 0 @@ -471,7 +474,7 @@ def cleanDir(path, section, subsection): "Directory %s still contains %s unprocessed file(s), skipping ..." % (path, num_files), 'CLEANDIRS') - logger.info("Directory %s has already been processed, removing ..." % (path), 'CLEANDIRS') + logger.info("Directory %s has been processed, removing ..." % (path), 'CLEANDIRS') shutil.rmtree(path) def create_torrent_class(clientAgent):