qf = QueueFile()
qf.queue_id = self.queue_id
qf.lastused = datetime.now()
- qf.filename = dest
+ qf.filename = poolfile_basename
targetpath = qf.fullpath
queuepath = os.path.join(self.path, poolfile_basename)
################################################################################
-class KnownChange(object):
+class DBChange(object):
def __init__(self, *args, **kwargs):
pass
def __repr__(self):
- return '<KnownChange %s>' % self.changesname
+ return '<DBChange %s>' % self.changesname
-__all__.append('KnownChange')
+__all__.append('DBChange')
@session_wrapper
-def get_knownchange(filename, session=None):
+def get_dbchange(filename, session=None):
"""
- returns knownchange object for given C{filename}.
+ returns DBChange object for given C{filename}.
@type archive: string
@param archive: the name of the arhive
@return: Archive object for the given name (None if not present)
"""
- q = session.query(KnownChange).filter_by(changesname=filename)
+ q = session.query(DBChange).filter_by(changesname=filename)
try:
return q.one()
except NoResultFound:
return None
-__all__.append('get_knownchange')
+__all__.append('get_dbchange')
################################################################################
def add_dsc_to_db(u, filename, session=None):
entry = u.pkg.files[filename]
source = DBSource()
+ pfs = []
source.source = u.pkg.dsc["source"]
source.version = u.pkg.dsc["version"] # NB: not files[file]["version"], that has no epoch
filename = entry["pool name"] + filename
poolfile = add_poolfile(filename, entry, dsc_location_id, session)
session.flush()
+ pfs.append(poolfile)
entry["files id"] = poolfile.file_id
source.poolfile_id = entry["files id"]
# FIXME: needs to check for -1/-2 and or handle exception
if found and obj is not None:
files_id = obj.file_id
+ pfs.append(obj)
# If still not found, add it
if files_id is None:
dentry["sha1sum"] = dfentry["sha1sum"]
dentry["sha256sum"] = dfentry["sha256sum"]
poolfile = add_poolfile(filename, dentry, dsc_location_id, session)
+ pfs.append(poolfile)
files_id = poolfile.file_id
df.poolfile_id = files_id
session.flush()
- return dsc_component, dsc_location_id
+ return dsc_component, dsc_location_id, pfs
__all__.append('add_dsc_to_db')
filename = entry["pool name"] + filename
fullpath = os.path.join(cnf["Dir::Pool"], filename)
if not entry.get("location id", None):
- entry["location id"] = get_location(cnf["Dir::Pool"], entry["component"], utils.where_am_i(), session).location_id
+ entry["location id"] = get_location(cnf["Dir::Pool"], entry["component"], session=session).location_id
- if not entry.get("files id", None):
+ if entry.get("files id", None):
+ poolfile = get_poolfile_by_id(bin.poolfile_id)
+ bin.poolfile_id = entry["files id"]
+ else:
poolfile = add_poolfile(filename, entry, entry["location id"], session)
- entry["files id"] = poolfile.file_id
-
- bin.poolfile_id = entry["files id"]
+ bin.poolfile_id = entry["files id"] = poolfile.file_id
# Find source id
bin_sources = get_sources_from_name(entry["source package"], entry["source version"], session=session)
# session.rollback()
# raise MissingContents, "No contents stored for package %s, and couldn't determine contents of %s" % (bin.package, filename)
+ return poolfile
+
__all__.append('add_deb_to_db')
################################################################################
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)
self.tbl_files = Table('files', self.db_meta, autoload=True)
self.tbl_fingerprint = Table('fingerprint', self.db_meta, autoload=True)
self.tbl_keyrings = Table('keyrings', self.db_meta, autoload=True)
- self.tbl_known_changes = Table('known_changes', self.db_meta, autoload=True)
+ self.tbl_changes = Table('changes', self.db_meta, autoload=True)
self.tbl_keyring_acl_map = Table('keyring_acl_map', self.db_meta, autoload=True)
self.tbl_location = Table('location', self.db_meta, autoload=True)
self.tbl_maintainer = Table('maintainer', self.db_meta, autoload=True)
properties = dict(keyring_name = self.tbl_keyrings.c.name,
keyring_id = self.tbl_keyrings.c.id))
- mapper(KnownChange, self.tbl_known_changes,
- properties = dict(known_change_id = self.tbl_known_changes.c.id,
+ mapper(DBChange, self.tbl_changes,
+ properties = dict(change_id = self.tbl_changes.c.id,
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))
mapper(ChangePendingSource, self.tbl_changes_pending_source,
properties = dict(change_pending_source_id = self.tbl_changes_pending_source.c.id,
- change = relation(KnownChange),
+ change = relation(DBChange),
maintainer = relation(Maintainer,
primaryjoin=(self.tbl_changes_pending_source.c.maintainer_id==self.tbl_maintainer.c.id)),
changedby = relation(Maintainer,
source_files = relation(ChangePendingFile,
secondary=self.tbl_changes_pending_source_files,
backref="pending_sources")))
-
mapper(KeyringACLMap, self.tbl_keyring_acl_map,
properties = dict(keyring_acl_map_id = self.tbl_keyring_acl_map.c.id,
keyring = relation(Keyring, backref="keyring_acl_map"),