Fix for download info

This commit is contained in:
echel0n 2014-04-22 07:31:57 -07:00
commit 4332ce5967
4 changed files with 17 additions and 17 deletions

View file

@ -197,7 +197,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
resume_torrent(clientAgent, inputHash, inputID, result, inputName)
else:
# update download status in our DB
update_downloadInfoStatus(inputDirectory, 1)
update_downloadInfoStatus(inputName, 1)
# cleanup our processing folders of any misc unwanted files and empty directories
cleanProcDirs()
@ -315,13 +315,13 @@ def main(args):
inputHash = None
inputID = None
logger.info("Checking database for download info ...")
downloadInfo = get_downloadInfo(dirName, 0)
logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName)))
downloadInfo = get_downloadInfo(os.path.basename(dirName), 0)
if downloadInfo:
clientAgent = downloadInfo['client_agent']
inputHash = downloadInfo['input_hash']
inputID = downloadInfo['input_id']
logger.info("Found download info for directory %s, setting variables now ..." % (dirName))
logger.info("Found download info for %s, setting variables now ..." % (os.path.basename(dirName)))
logger.info("Running %s:%s as a manual run for folder %s ..." % (section, category, dirName))
results = processTorrent(dirName, os.path.basename(dirName), category, inputHash, inputID, clientAgent)

View file

@ -329,7 +329,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
if result == 0:
# update download status in our DB
update_downloadInfoStatus(inputDirectory, 1)
update_downloadInfoStatus(inputName, 1)
# cleanup our processing folders of any misc unwanted files and empty directories
cleanProcDirs()
@ -442,12 +442,12 @@ def main(args, section=None):
clientAgent = 'manual'
download_id = None
logger.info("Checking database for download info ...")
downloadInfo = get_downloadInfo(dirName, 0)
logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName)))
downloadInfo = get_downloadInfo(os.path.basename(dirName), 0)
if downloadInfo:
clientAgent = downloadInfo['client_agent']
download_id = downloadInfo['input_id']
logger.info("Found download info for directory %s, setting variables now ..." % (dirName))
logger.info("Found download info for %s, setting variables now ..." % (os.path.basename(dirName)))
logger.info("Starting manual run for %s:%s - Folder:%s" % (section, category, dirName))
results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent, download_id=download_id, inputCategory=category)

View file

@ -25,7 +25,7 @@ class InitialSchema(nzbToMediaDB.SchemaUpgrade):
if not self.hasTable("history") and not self.hasTable("db_version"):
queries = [
"CREATE TABLE db_version (db_version INTEGER);",
"CREATE TABLE downloads (input_directory TEXT PRIMARY KEY, input_name TEXT, input_hash TEXT, input_id TEXT, client_agent TEXT, status INTEGER, last_update NUMERIC);",
"CREATE TABLE downloads (input_directory TEXT, input_name TEXT PRIMARY KEY, input_hash TEXT, input_id TEXT, client_agent TEXT, status INTEGER, last_update NUMERIC);",
"INSERT INTO db_version (db_version) VALUES (1);"
]
for query in queries:

View file

@ -730,19 +730,19 @@ def backupVersionedFile(old_file, version):
return True
def update_downloadInfoStatus(inputDirectory, status):
logger.db("Updating status of our download in the DB to %s" % (status))
def update_downloadInfoStatus(inputName, status):
logger.db("Updating status of our download %s in the DB to %s" % (inputName, status))
myDB = nzbToMediaDB.DBConnection()
myDB.action("UPDATE downloads SET status=?, last_update=? WHERE input_directory=?",
[status, datetime.date.today().toordinal(), inputDirectory])
myDB.action("UPDATE downloads SET status=?, last_update=? WHERE input_name=?",
[status, datetime.date.today().toordinal(), inputName])
def get_downloadInfo(inputDirectory, status):
logger.db("Getting download info from the DB for directory %s" % (inputDirectory))
def get_downloadInfo(inputName, status):
logger.db("Getting download info for %s from the DB" % (inputName))
myDB = nzbToMediaDB.DBConnection()
sqlResults = myDB.select("SELECT * FROM downloads WHERE input_directory=? AND status=?",
[inputDirectory, status])
sqlResults = myDB.select("SELECT * FROM downloads WHERE input_name=? AND status=?",
[inputName, status])
return sqlResults