]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/contents.py
Add by-hash support
[dak.git] / daklib / contents.py
index f9c1feb15708464e7e6a91e940d5552e8afa8dee..75fb5e59b96d7c06a54fcc2a0b2dc4c2b2103ae7 100644 (file)
@@ -134,14 +134,9 @@ select bc.file, string_agg(o.section || '/' || b.package, ',' order by b.package
         '''
         Returns the header for the Contents files as a string.
         '''
-        header_file = None
-        try:
-            filename = os.path.join(Config()['Dir::Templates'], 'contents')
-            header_file = open(filename)
+        filename = os.path.join(Config()['Dir::Templates'], 'contents')
+        with open(filename) as header_file:
             return header_file.read()
-        finally:
-            if header_file:
-                header_file.close()
 
     def write_file(self):
         '''
@@ -304,6 +299,11 @@ class ContentsWriter(object):
         deb_id = get_override_type('deb', session).overridetype_id
         udeb_id = get_override_type('udeb', session).overridetype_id
         pool = Pool()
+
+        # Lock tables so that nobody can change things underneath us
+        session.execute("LOCK TABLE bin_contents IN SHARE MODE")
+        session.execute("LOCK TABLE src_contents IN SHARE MODE")
+
         for suite in suite_query:
             suite_id = suite.suite_id
             for component in component_query: