]> git.decadent.org.uk Git - dak.git/commitdiff
Break hardlink when writing Contents files.
authorTorsten Werner <twerner@debian.org>
Mon, 14 Mar 2011 21:07:40 +0000 (22:07 +0100)
committerTorsten Werner <twerner@debian.org>
Mon, 14 Mar 2011 21:07:40 +0000 (22:07 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/contents.py

index 4a6330f827fdd349306890f14a09196af457ac8d..bbbacd4a3f73172e4c021e8beda380d2351ac850 100755 (executable)
@@ -191,7 +191,9 @@ select bc.file, o.section || '/' || b.package as package
         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, o.section || '/' || b.package as package
         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):