From c4d5e480b51a79834cad3b5d4960745f9a9816a2 Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 6 Aug 2014 21:55:17 +0800 Subject: [PATCH] Halt postprocessing if temporary btsync files are detected --- sickbeard/helpers.py | 9 +++++++++ sickbeard/processTV.py | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 378b000d..5305f6f5 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -136,6 +136,15 @@ def replaceExtension(filename, newExt): return sepFile[0] + "." + newExt +def isBtsyncFile(filename): + sepFile = filename.rpartition(".") + + if sepFile[2].lower() == '!sync': + return True + else: + return False + + def isMediaFile(filename): # ignore samples if re.search('(^|[\W_])(sample\d*)[\W_]', filename, re.I): diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py index 4beefa71..a02c09f2 100644 --- a/sickbeard/processTV.py +++ b/sickbeard/processTV.py @@ -138,6 +138,13 @@ def processDir(dirName, nzbName=None, process_method=None, force=False, is_prior path, dirs, files = get_path_dir_files(dirName, nzbName, type) + btsyncFiles = filter(helpers.isBtsyncFile, files) + + # Don't post process if files are still being synced from btsync + if btsyncFiles: + returnStr += logHelper(u"Found .!sync files, skipping post processing", logger.ERROR) + return returnStr + returnStr += logHelper(u"PostProcessing Path: " + path, logger.DEBUG) returnStr += logHelper(u"PostProcessing Dirs: " + str(dirs), logger.DEBUG) @@ -179,6 +186,13 @@ def processDir(dirName, nzbName=None, process_method=None, force=False, is_prior for processPath, processDir, fileList in ek.ek(os.walk, ek.ek(os.path.join, path, dir), topdown=False): + btsyncFiles = filter(helpers.isBtsyncFile, fileList) + + # Don't post process if files are still being synced from btsync + if btsyncFiles: + returnStr += logHelper(u"Found .!sync files, skipping post processing", logger.ERROR) + return returnStr + rarFiles = filter(helpers.isRarFile, fileList) rarContent = unRAR(processPath, rarFiles, force) fileList = set(fileList + rarContent)