X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fcontents.py;h=75fb5e59b96d7c06a54fcc2a0b2dc4c2b2103ae7;hb=391f5ec09a119131dc846b796ca791f4cecc69e4;hp=f9c1feb15708464e7e6a91e940d5552e8afa8dee;hpb=1eeb90f6bf381e10fcd8f0a04437883b443855d5;p=dak.git diff --git a/daklib/contents.py b/daklib/contents.py index f9c1feb1..75fb5e59 100644 --- a/daklib/contents.py +++ b/daklib/contents.py @@ -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: