X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fcontents.py;h=27ffdda6cf71879c75abd34b01ee98d3b2fe796c;hb=58f226d25d6c19c1e1283fddc2f81120839d296f;hp=65e7e3f1c31dedd1f0fc660550d0b0ed3f077268;hpb=08b2323f564252585cce5ce8d10a09f9861dff80;p=dak.git diff --git a/daklib/contents.py b/daklib/contents.py index 65e7e3f1..27ffdda6 100755 --- a/daklib/contents.py +++ b/daklib/contents.py @@ -92,7 +92,7 @@ unique_override as where o.suite = :overridesuite and o.type = :type_id and o.section = s.id and o.component = :component) -select bc.file, substring(o.section from position('/' in o.section) + 1) || '/' || b.package as package +select bc.file, o.section || '/' || b.package as package from newest_binaries b, bin_contents bc, unique_override o where b.id = bc.binary_id and o.package = b.package order by bc.file, b.package''' @@ -120,7 +120,7 @@ unique_override as where o.suite = :overridesuite and o.type = :type_id and o.section = s.id order by o.package, s.section, o.modified desc) -select bc.file, substring(o.section from position('/' in o.section) + 1) || '/' || b.package as package +select bc.file, o.section || '/' || b.package as package from newest_binaries b, bin_contents bc, unique_override o where b.id = bc.binary_id and o.package = b.package order by bc.file, b.package''' @@ -191,7 +191,9 @@ select bc.file, substring(o.section from position('/' in o.section) + 1) || '/' Write the output file. ''' command = ['gzip', '--rsyncable'] - output_file = open(self.output_filename(), 'w') + final_filename = self.output_filename() + temp_filename = final_filename + '.new' + output_file = open(temp_filename, 'w') gzip = Popen(command, stdin = PIPE, stdout = output_file) gzip.stdin.write(self.get_header()) for item in self.fetch(): @@ -199,6 +201,9 @@ select bc.file, substring(o.section from position('/' in o.section) + 1) || '/' gzip.stdin.close() output_file.close() gzip.wait() + os.remove(final_filename) + os.rename(temp_filename, final_filename) + os.chmod(final_filename, 0664) @classmethod def write_all(class_, suite_names = [], force = False): @@ -252,14 +257,12 @@ class ContentsScanner(object): ''' session = DBConn().session() binary = session.query(DBBinary).get(self.binary_id) - for filename in binary.scan_contents(): + fileset = set(binary.scan_contents()) + if len(fileset) == 0: + fileset.add('EMPTY_PACKAGE') + for filename in fileset: binary.contents.append(BinContents(file = filename)) - try: - session.commit() - except IntegrityError: - session.rollback() - binary.contents.append(BinContents(file = 'DUPLICATE_FILENAMES')) - session.commit() + session.commit() session.close() @classmethod