]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/dbconn.py
Merge commit 'stew/contents' into merge
[dak.git] / daklib / dbconn.py
index 9b37af700f631b08fb7990dd4434d440cd6d8d54..49468a7556c250f314fe2370700f4c3cc7b2f98e 100755 (executable)
@@ -231,6 +231,17 @@ __all__.append('BinAssociation')
 
 ################################################################################
 
+class BinContents(object):
+    def __init__(self, *args, **kwargs):
+        pass
+
+    def __repr__(self):
+        return '<BinContents (%s, %s)>' % (self.binary, self.filename)
+
+__all__.append('BinContents')
+
+################################################################################
+
 class DBBinary(object):
     def __init__(self, *args, **kwargs):
         pass
@@ -458,15 +469,6 @@ __all__.append('DBConfig')
 
 ################################################################################
 
-class ContentFilename(object):
-    def __init__(self, *args, **kwargs):
-        pass
-
-    def __repr__(self):
-        return '<ContentFilename %s>' % self.filename
-
-__all__.append('ContentFilename')
-
 @session_wrapper
 def get_or_set_contents_file_id(filename, session=None):
     """
@@ -633,28 +635,14 @@ def insert_content_paths(binary_id, fullpaths, session=None):
         # Insert paths
         pathcache = {}
         for fullpath in fullpaths:
-            # Get the necessary IDs ...
-            (path, file) = os.path.split(fullpath)
-
-            filepath_id = get_or_set_contents_path_id(path, session)
-            filename_id = get_or_set_contents_file_id(file, session)
-
-            pathcache[fullpath] = (filepath_id, filename_id)
+            if fullpath.startswith( './' ):
+                fullpath = fullpath[2:]
 
-        for fullpath, dat in pathcache.items():
-            ca = ContentAssociation()
-            ca.binary_id = binary_id
-            ca.filepath_id = dat[0]
-            ca.filename_id = dat[1]
-            session.add(ca)
+            session.execute( "INSERT INTO bin_contents ( file, binary_id ) VALUES ( :filename, :id )", { 'filename': fullpath, 'id': binary_id}  )
 
-        # Only commit if we set up the session ourself
+        session.commit()
         if privatetrans:
-            session.commit()
             session.close()
-        else:
-            session.flush()
-
         return True
 
     except:
@@ -2354,6 +2342,7 @@ class DBConn(Singleton):
                                  binary_id = self.tbl_bin_associations.c.bin,
                                  binary = relation(DBBinary)))
 
+
         mapper(DBBinary, self.tbl_binaries,
                properties = dict(binary_id = self.tbl_binaries.c.id,
                                  package = self.tbl_binaries.c.package,
@@ -2388,24 +2377,6 @@ class DBConn(Singleton):
         mapper(DBConfig, self.tbl_config,
                properties = dict(config_id = self.tbl_config.c.id))
 
-        mapper(ContentAssociation, self.tbl_content_associations,
-               properties = dict(ca_id = self.tbl_content_associations.c.id,
-                                 filename_id = self.tbl_content_associations.c.filename,
-                                 filename    = relation(ContentFilename),
-                                 filepath_id = self.tbl_content_associations.c.filepath,
-                                 filepath    = relation(ContentFilepath),
-                                 binary_id   = self.tbl_content_associations.c.binary_pkg,
-                                 binary      = relation(DBBinary)))
-
-
-        mapper(ContentFilename, self.tbl_content_file_names,
-               properties = dict(cafilename_id = self.tbl_content_file_names.c.id,
-                                 filename = self.tbl_content_file_names.c.file))
-
-        mapper(ContentFilepath, self.tbl_content_file_paths,
-               properties = dict(cafilepath_id = self.tbl_content_file_paths.c.id,
-                                 filepath = self.tbl_content_file_paths.c.path))
-
         mapper(DSCFile, self.tbl_dsc_files,
                properties = dict(dscfile_id = self.tbl_dsc_files.c.id,
                                  source_id = self.tbl_dsc_files.c.source,
@@ -2467,13 +2438,6 @@ class DBConn(Singleton):
                properties = dict(overridetype = self.tbl_override_type.c.type,
                                  overridetype_id = self.tbl_override_type.c.id))
 
-        mapper(PendingContentAssociation, self.tbl_pending_content_associations,
-               properties = dict(pca_id = self.tbl_pending_content_associations.c.id,
-                                 filepath_id = self.tbl_pending_content_associations.c.filepath,
-                                 filepath = relation(ContentFilepath),
-                                 filename_id = self.tbl_pending_content_associations.c.filename,
-                                 filename = relation(ContentFilename)))
-
         mapper(Priority, self.tbl_priority,
                properties = dict(priority_id = self.tbl_priority.c.id))