FIX: Fix for post-processing files that are retained in the folder monitor location (ie. torrent-seeding), which would result in the same file being post-processed several times over

This commit is contained in:
evilhero 2017-05-09 14:08:26 -04:00
parent ac2281e801
commit 4d5b384c82
3 changed files with 54 additions and 31 deletions

View File

@ -316,6 +316,14 @@ class PostProcessor(object):
return
logger.info('I have located ' + str(filelist['comiccount']) + ' files that I should be able to post-process. Continuing...')
#load the hashes for torrents so continual post-processing of same isseus doesn't occur.
pp_crclist = []
if mylar.ENABLE_TORRENTS:
pp_crc = myDB.select("SELECT a.crc, b.IssueID FROM Snatched as a INNER JOIN issues as b ON a.IssueID=b.IssueID WHERE a.Status='Post-Processed' and a.crc is not NULL and (b.Status='Downloaded' or b.status='Archived ORDER BY b.IssueDate')")
for pp in pp_crc:
pp_crclist.append({'IssueID': pp['IssueID'],
'crc': pp['crc']})
#preload the entire ALT list in here.
alt_list = []
alt_db = myDB.select("SELECT * FROM Comics WHERE AlternateSearch != 'None'")
@ -331,6 +339,14 @@ class PostProcessor(object):
manual_arclist = []
for fl in filelist['comiclist']:
if mylar.ENABLE_TORRENTS:
crcchk = None
tcrc = helpers.crc(os.path.join(fl['comiclocation'], fl['comicfilename']))
crcchk = [x for x in pp_crclist if tcrc == x['crc']]
if crcchk:
logger.fdebug('Already post-processed this item %s - Ignoring' % crcchk)
continue
as_d = filechecker.FileChecker()
as_dinfo = as_d.dynamic_replace(helpers.conversion(fl['series_name']))
mod_seriesname = as_dinfo['mod_seriesname']
@ -576,7 +592,6 @@ class PostProcessor(object):
#we should setup for manual post-processing of story-arc issues here
#we can also search by ComicID to just grab those particular arcs as an alternative as well (not done)
logger.fdebug(module + ' Now Checking if the issue also resides in one of the storyarc\'s that I am watching.')
#as_d = filechecker.FileChecker()
#as_dinfo = as_d.dynamic_replace(helpers.conversion(fl['series_name']))
@ -642,6 +657,7 @@ class PostProcessor(object):
if k is None or k == 'None':
pass
else:
logger.fdebug(module + ' Now Checking if the issue also resides in one of the storyarc\'s that I am watching.')
arcm = filechecker.FileChecker(watchcomic=k, Publisher=v[i]['ArcValues']['ComicPublisher'], manual=v[i]['WatchValues'])
arcmatch = arcm.matchIT(fl)
logger.info('arcmatch: ' + str(arcmatch))
@ -771,6 +787,9 @@ class PostProcessor(object):
#tag the meta.
metaresponse = None
crcvalue = helpers.crc(ofilename)
if mylar.ENABLE_META:
logger.info('[STORY-ARC POST-PROCESSING] Metatagging enabled - proceeding...')
try:
@ -801,6 +820,16 @@ class PostProcessor(object):
else:
dfilename = ml['Filename']
if metaresponse:
src_location = odir
grab_src = os.path.join(src_location, ofilename)
else:
src_location = ofilename
grab_src = ofilename
logger.fdebug(module + ' Source Path : ' + grab_src)
checkdirectory = filechecker.validateAndCreateDirectory(grdst, True, module=module)
if not checkdirectory:
logger.warn(module + ' Error trying to validate/create directory. Aborting this process at this time.')
@ -827,13 +856,6 @@ class PostProcessor(object):
grab_dst = os.path.join(grdst, dfilename)
logger.fdebug(module + ' Destination Path : ' + grab_dst)
if metaresponse:
src_location = odir
grab_src = os.path.join(src_location, ofilename)
else:
src_location = ofilename
grab_src = ofilename
logger.fdebug(module + ' Source Path : ' + grab_src)
logger.info(module + '[ONE-OFF MODE][' + mylar.ARC_FILEOPS.upper() + '] ' + grab_src + ' into directory : ' + grab_dst)
@ -1044,6 +1066,8 @@ class PostProcessor(object):
#tag the meta.
metaresponse = None
crcvalue = helpers.crc(os.path.join(self.nzb_folder, ofilename))
#if a one-off download from the pull-list, will not have an issueid associated with it, and will fail to due conversion/tagging.
#if altpull/2 method is being used, issueid may already be present so conversion/tagging is possible with some additional fixes.
if all([mylar.ENABLE_META, sandwich is not None, 'S' in sandwich]):
@ -1073,16 +1097,14 @@ class PostProcessor(object):
dfilename = ofilename
#if sandwich is not None and 'S' in sandwich:
# if mylar.STORYARCDIR:
# grdst = storyarcd
# else:
# grdst = mylar.DESTINATION_DIR
#else:
# if mylar.GRABBAG_DIR:
# grdst = mylar.GRABBAG_DIR
# else:
# grdst = mylar.DESTINATION_DIR
if metaresponse:
src_location = odir
else:
src_location = self.nzb_folder
grab_src = os.path.join(src_location, ofilename)
self._log("Source Path : " + grab_src)
logger.info(module + ' Source Path : ' + grab_src)
checkdirectory = filechecker.validateAndCreateDirectory(grdst, True, module=module)
if not checkdirectory:
@ -1116,14 +1138,6 @@ class PostProcessor(object):
self._log("Destination Path : " + grab_dst)
logger.info(module + ' Destination Path : ' + grab_dst)
if metaresponse:
src_location = odir
else:
src_location = self.nzb_folder
grab_src = os.path.join(src_location, ofilename)
self._log("Source Path : " + grab_src)
logger.info(module + ' Source Path : ' + grab_src)
logger.info(module + '[' + mylar.FILE_OPTS + '] ' + str(ofilename) + ' into directory : ' + str(grab_dst))
@ -1571,8 +1585,11 @@ class PostProcessor(object):
#tidy-up we can remove the empty directory too. odir is the original COMPLETE path at this point
if ml is None:
subpath = odir
crcvalue = helpers.crc(os.path.join(odir, ofilename))
else:
subpath = os.path.split(ml['ComicLocation'])[0]
crcvalue = helpers.crc(ml['ComicLocation'])
#tag the meta.
if mylar.ENABLE_META:
@ -1859,10 +1876,10 @@ class PostProcessor(object):
#update snatched table to change status to Downloaded
if annchk == "no":
updater.foundsearch(comicid, issueid, down=downtype, module=module)
updater.foundsearch(comicid, issueid, down=downtype, module=module, crc=crcvalue)
dispiss = 'issue: ' + issuenumOG
else:
updater.foundsearch(comicid, issueid, mode='want_ann', down=downtype, module=module)
updater.foundsearch(comicid, issueid, mode='want_ann', down=downtype, module=module, crc=crcvalue)
if 'annual' not in series.lower():
dispiss = 'annual issue: ' + issuenumOG
else:

View File

@ -1797,7 +1797,7 @@ def dbcheck():
c.execute('CREATE TABLE IF NOT EXISTS comics (ComicID TEXT UNIQUE, ComicName TEXT, ComicSortName TEXT, ComicYear TEXT, DateAdded TEXT, Status TEXT, IncludeExtras INTEGER, Have INTEGER, Total INTEGER, ComicImage TEXT, ComicPublisher TEXT, ComicLocation TEXT, ComicPublished TEXT, NewPublish TEXT, LatestIssue TEXT, LatestDate TEXT, Description TEXT, QUALalt_vers TEXT, QUALtype TEXT, QUALscanner TEXT, QUALquality TEXT, LastUpdated TEXT, AlternateSearch TEXT, UseFuzzy TEXT, ComicVersion TEXT, SortOrder INTEGER, DetailURL TEXT, ForceContinuing INTEGER, ComicName_Filesafe TEXT, AlternateFileName TEXT, ComicImageURL TEXT, ComicImageALTURL TEXT, DynamicComicName TEXT, AllowPacks TEXT, Type TEXT, Corrected_SeriesYear TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS issues (IssueID TEXT, ComicName TEXT, IssueName TEXT, Issue_Number TEXT, DateAdded TEXT, Status TEXT, Type TEXT, ComicID TEXT, ArtworkURL Text, ReleaseDate TEXT, Location TEXT, IssueDate TEXT, Int_IssueNumber INT, ComicSize TEXT, AltIssueNumber TEXT, IssueDate_Edit TEXT, ImageURL TEXT, ImageURL_ALT TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS snatched (IssueID TEXT, ComicName TEXT, Issue_Number TEXT, Size INTEGER, DateAdded TEXT, Status TEXT, FolderName TEXT, ComicID TEXT, Provider TEXT, Hash TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS snatched (IssueID TEXT, ComicName TEXT, Issue_Number TEXT, Size INTEGER, DateAdded TEXT, Status TEXT, FolderName TEXT, ComicID TEXT, Provider TEXT, Hash TEXT, crc TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS upcoming (ComicName TEXT, IssueNumber TEXT, ComicID TEXT, IssueID TEXT, IssueDate TEXT, Status TEXT, DisplayComicName TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS nzblog (IssueID TEXT, NZBName TEXT, SARC TEXT, PROVIDER TEXT, ID TEXT, AltNZBName TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS weekly (SHIPDATE TEXT, PUBLISHER TEXT, ISSUE TEXT, COMIC VARCHAR(150), EXTRA TEXT, STATUS TEXT, ComicID TEXT, IssueID TEXT, CV_Last_Update TEXT, DynamicName TEXT, weeknumber TEXT, year TEXT, rowid INTEGER PRIMARY KEY)')
@ -2178,6 +2178,11 @@ def dbcheck():
except sqlite3.OperationalError:
c.execute('ALTER TABLE snatched ADD COLUMN Hash TEXT')
try:
c.execute('SELECT crc from snatched')
except sqlite3.OperationalError:
c.execute('ALTER TABLE snatched ADD COLUMN crc TEXT')
## -- Upcoming Table --
try:

View File

@ -644,7 +644,7 @@ def nzblog(IssueID, NZBName, ComicName, SARC=None, IssueArcID=None, id=None, pro
myDB.upsert("nzblog", newValue, controlValue)
def foundsearch(ComicID, IssueID, mode=None, down=None, provider=None, SARC=None, IssueArcID=None, module=None, hash=None):
def foundsearch(ComicID, IssueID, mode=None, down=None, provider=None, SARC=None, IssueArcID=None, module=None, hash=None, crc=None):
# When doing a Force Search (Wanted tab), the resulting search calls this to update.
# this is all redudant code that forceRescan already does.
@ -774,7 +774,8 @@ def foundsearch(ComicID, IssueID, mode=None, down=None, provider=None, SARC=None
"ComicID": ComicID,
"Issue_Number": IssueNum,
"DateAdded": helpers.now(),
"Status": downstatus
"Status": downstatus,
"crc": crc
}
myDB.upsert("snatched", newsnatchValues, snatchedupdate)