]> git.decadent.org.uk Git - dak.git/commitdiff
dak/export.py, daklib/policy.py: ignore existing files
authorAnsgar Burchardt <ansgar@debian.org>
Sun, 12 Aug 2012 08:57:24 +0000 (10:57 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Sun, 12 Aug 2012 08:57:24 +0000 (10:57 +0200)
The same upstream tarball can be used by multiple uploads so we have to
ignore already existing files.

dak/export.py
daklib/policy.py

index 8545167cc54ef55475eb79ccaa6f25ea03250698..841e3361386d4a70323a35067ad4c673d509d4ea 100644 (file)
@@ -69,7 +69,7 @@ def main(argv=None):
 
     for u in uploads:
         print "Processing {0}...".format(u.changes.changesname)
-        UploadCopy(u).export(directory, symlink=symlink)
+        UploadCopy(u).export(directory, symlink=symlink, ignore_existing=True)
 
 if __name__ == '__main__':
     main()
index eef18a4f343f4bde8fe8f17bb1900d4b2d2893d0..cfb0e1df0446dcf9a3bd8fc8a4ce705181ea7a5c 100644 (file)
@@ -49,7 +49,7 @@ class UploadCopy(object):
         self.directory = None
         self.upload = upload
 
-    def export(self, directory, mode=None, symlink=True):
+    def export(self, directory, mode=None, symlink=True, ignore_existing=False):
         """export a copy of the upload
 
         @type  directory: str
@@ -60,6 +60,9 @@ class UploadCopy(object):
 
         @type  symlink: bool
         @param symlink: use symlinks instead of copying the files
+
+        @type  ignore_existing: bool
+        @param ignore_existing: ignore already existing files
         """
         with FilesystemTransaction() as fs:
             source = self.upload.source
@@ -69,22 +72,27 @@ class UploadCopy(object):
                 for dsc_file in source.srcfiles:
                     f = dsc_file.poolfile
                     dst = os.path.join(directory, os.path.basename(f.filename))
-                    fs.copy(f.fullpath, dst, mode=mode, symlink=symlink)
+                    if not os.path.exists(dst) or not ignore_existing:
+                        fs.copy(f.fullpath, dst, mode=mode, symlink=symlink)
+
             for binary in self.upload.binaries:
                 f = binary.poolfile
                 dst = os.path.join(directory, os.path.basename(f.filename))
-                fs.copy(f.fullpath, dst, mode=mode, symlink=symlink)
+                if not os.path.exists(dst) or not ignore_existing:
+                    fs.copy(f.fullpath, dst, mode=mode, symlink=symlink)
 
             # copy byhand files
             for byhand in self.upload.byhand:
                 src = os.path.join(queue.path, byhand.filename)
                 dst = os.path.join(directory, byhand.filename)
-                fs.copy(src, dst, mode=mode, symlink=symlink)
+                if not os.path.exists(dst) or not ignore_existing:
+                    fs.copy(src, dst, mode=mode, symlink=symlink)
 
             # copy .changes
             src = os.path.join(queue.path, self.upload.changes.changesname)
             dst = os.path.join(directory, self.upload.changes.changesname)
-            fs.copy(src, dst, mode=mode, symlink=symlink)
+            if not os.path.exists(dst) or not ignore_existing:
+                fs.copy(src, dst, mode=mode, symlink=symlink)
 
     def __enter__(self):
         assert self.directory is None