X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fcontents.py;h=1ce5779a09393a8f127bd78ab4ab20ab131f03fa;hb=be1cb05f94229e2ea8e1dbc4322709117ae41fc5;hp=449fb88e126fdc13038c1fd512edf0631bfff060;hpb=3f673e29a7eccfbf1ef4f162dfe5bc40af84cd81;p=dak.git diff --git a/daklib/contents.py b/daklib/contents.py index 449fb88e..1ce5779a 100755 --- a/daklib/contents.py +++ b/daklib/contents.py @@ -144,19 +144,17 @@ select bc.file, string_agg(o.section || '/' || b.package, ',' order by b.package ''' return [item for item in self.fetch()] - def output_filename(self): + def writer(self): ''' - Returns the name of the output file. + Returns a writer object. ''' values = { - 'root': Config()['Dir::Root'], - 'suite': self.suite.suite_name, - 'architecture': self.architecture.arch_string + 'suite': self.suite.suite_name, + 'architecture': self.architecture.arch_string, } - if self.component is None: - return "%(root)s/dists/%(suite)s/Contents-%(architecture)s.gz" % values - values['component'] = self.component.component_name - return "%(root)s/dists/%(suite)s/%(component)s/Contents-%(architecture)s.gz" % values + if self.component is not None: + values['component'] = self.component.component_name + return BinaryContentsWriter(values) def get_header(self): ''' @@ -175,19 +173,12 @@ select bc.file, string_agg(o.section || '/' || b.package, ',' order by b.package ''' Write the output file. ''' - command = ['gzip', '--rsyncable'] - 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()) + writer = self.writer() + file = writer.open() + file.write(self.get_header()) for item in self.fetch(): - gzip.stdin.write(item) - gzip.stdin.close() - output_file.close() - gzip.wait() - os.chmod(temp_filename, 0664) - os.rename(temp_filename, final_filename) + file.write(item) + writer.close() class SourceContentsWriter(object):