From: Mike O'Connor Date: Fri, 13 Nov 2009 19:28:26 +0000 (+0000) Subject: import_new_files is close to working, right now it misses on the non-null constraints... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce92830dafad9b8d40a0e9e161a68efea8beef8f;p=dak import_new_files is close to working, right now it misses on the non-null constraints for sha1sum sha256sum Signed-off-by: Mike O'Connor --- diff --git a/dak/import_new_files.py b/dak/import_new_files.py old mode 100644 new mode 100755 index 67fdf33d..ff49e6c3 --- a/dak/import_new_files.py +++ b/dak/import_new_files.py @@ -33,8 +33,10 @@ import os import logging import threading import glob -from daklib.dbconn import DBConn, get_dbchange +import apt_pkg +from daklib.dbconn import DBConn, get_dbchange, get_policy_queue, session_wrapper, ChangePendingFile from daklib.config import Config +from daklib.queue import Upload # where in dak.conf all of our configuration will be stowed options_prefix = "NewFiles" @@ -58,27 +60,40 @@ OPTIONS """ sys.exit(exit_code) -class ImportKnownChanges(object): +class ImportNewFiles(object): @session_wrapper def __init__(self, session=None): try: newq = get_policy_queue('new', session) for changes_fn in glob.glob(newq.path + "/*.changes"): - changes_bn = os.path.basename(fn) - chg = session.query(DBChange).filter_by(changesname=changes_bn).one() + changes_bn = os.path.basename(changes_fn) + chg = get_dbchange(changes_bn, session) u = Upload() - u.changes_file = changes_fn - u.load_changes(changes_fn) + success = u.load_changes(changes_fn) + u.pkg.changes_file = changes_bn + if not chg: + chg = u.pkg.add_known_changes(newq.path, newq.policy_queue_id, session) + session.add(chg) + + if not success: + log.critical("failed to load %s" % changes_fn) + sys.exit(1) + else: + log.critical("ACCLAIM: %s" % changes_fn) + + files=[] for chg_fn in u.pkg.files.keys(): cpf = ChangePendingFile() cpf.filename = chg_fn - cpf.size = self.files[chg_fn]['size'] - cpf.md5sum = self.files[chg_fn]['md5sum'] + cpf.size = u.pkg.files[chg_fn]['size'] + cpf.md5sum = u.pkg.files[chg_fn]['md5sum'] session.add(cpf) - chg.files.append(cpf) + files.append(cpf) + + chg.files = files session.commit() diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 034728d0..7388208e 100644 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -2843,7 +2843,7 @@ class DBConn(object): poolfiles = relation(PoolFile, secondary=self.tbl_changes_pool_files, backref="changeslinks"), - filetime = self.tbl_changes.c.filetime, + seen = self.tbl_changes.c.seen, source = self.tbl_changes.c.source, binaries = self.tbl_changes.c.binaries, architecture = self.tbl_changes.c.architecture,