From d3a3c234a460e8c4f63fc7eaab651585e986d7c0 Mon Sep 17 00:00:00 2001 From: Mark Hymers Date: Sat, 31 Oct 2009 11:02:55 +0000 Subject: [PATCH] fix up existing changes file handling Signed-off-by: Mark Hymers --- dak/dakdb/update22.py | 6 ++++++ daklib/dbconn.py | 9 ++++++++- daklib/queue.py | 10 ++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/dak/dakdb/update22.py b/dak/dakdb/update22.py index e51e90ab..7234555e 100755 --- a/dak/dakdb/update22.py +++ b/dak/dakdb/update22.py @@ -166,6 +166,12 @@ def do_update(self): sha1sum TEXT NOT NULL, sha256sum TEXT NOT NULL )""") + c.execute("""CREATE TABLE changes_pending_files_map ( + file_id INT4 NOT NULL REFERENCES changes_pending_files (id), + change_id INT4 NOT NULL REFERENCES known_changes (id), + + PRIMARY KEY (file_id, change_id))""") + c.execute("""CREATE TABLE changes_pending_source ( id SERIAL PRIMARY KEY, change_id INT4 NOT NULL REFERENCES known_changes (id), diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 3c2b005e..7add55ff 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -2499,6 +2499,7 @@ class DBConn(Singleton): self.tbl_content_file_paths = Table('content_file_paths', self.db_meta, autoload=True) self.tbl_changes_pending_binary = Table('changes_pending_binaries', self.db_meta, autoload=True) self.tbl_changes_pending_files = Table('changes_pending_files', self.db_meta, autoload=True) + self.tbl_changes_pending_files_map = Table('changes_pending_files_map', self.db_meta, autoload=True) self.tbl_changes_pending_source = Table('changes_pending_source', self.db_meta, autoload=True) self.tbl_changes_pending_source_files = Table('changes_pending_source_files', self.db_meta, autoload=True) self.tbl_changes_pool_files = Table('changes_pool_files', self.db_meta, autoload=True) @@ -2616,7 +2617,13 @@ class DBConn(Singleton): poolfiles = relation(PoolFile, secondary=self.tbl_changes_pool_files, backref="changeslinks"), - files = relation(ChangePendingFile, backref="changesfile"))) + files = relation(ChangePendingFile, + secondary=self.tbl_changes_pending_files_map, + backref="changesfile"), + in_queue_id = self.tbl_changes.c.in_queue, + in_queue = relation(PolicyQueue, + primaryjoin=(self.tbl_changes.c.in_queue==self.tbl_policy_queue.c.id)), + approved_for_id = self.tbl_changes.c.approved_for)) mapper(ChangePendingBinary, self.tbl_changes_pending_binary, properties = dict(change_pending_binary_id = self.tbl_changes_pending_binary.c.id)) diff --git a/daklib/queue.py b/daklib/queue.py index 39dab347..15a83958 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -438,12 +438,6 @@ class Upload(object): self.pkg.changes["chopversion"] = re_no_epoch.sub('', self.pkg.changes["version"]) self.pkg.changes["chopversion2"] = re_no_revision.sub('', self.pkg.changes["chopversion"]) - # Check there isn't already a changes file of the same name in one - # of the queue directories. - base_filename = os.path.basename(filename) - if get_dbchange(base_filename): - self.rejects.append("%s: a file with this name already exists." % (base_filename)) - # Check the .changes is non-empty if not self.pkg.files: self.rejects.append("%s: nothing to do (Files field is empty)." % (base_filename)) @@ -822,8 +816,8 @@ class Upload(object): session = DBConn().session() try: - changes = session.query(DBChange).filter_by(changesname=base_filename).one() - if not changes.approved_for: + dbc = session.query(DBChange).filter_by(changesname=base_filename).one() + if dbc.in_queue is not None and dbc.in_queue.queue_name != 'unchecked': self.rejects.append("%s file already known to dak" % base_filename) except NoResultFound, e: # not known, good -- 2.39.5