[gtk-mac-bundler] Check that binary path hasn’t already been copied before trying to copy it.



commit af18a8d8467c38c1efeb3c4a6aaf2bb91c882ae6
Author: John Ralls <jralls ceridwen us>
Date:   Sun Jan 1 12:45:29 2017 -0800

    Check that binary path hasn’t already been copied before trying to copy it.

 bundler/bundler.py |    2 ++
 bundler/project.py |   24 ++++++++++++++----------
 2 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/bundler/bundler.py b/bundler/bundler.py
index 785e079..b118643 100644
--- a/bundler/bundler.py
+++ b/bundler/bundler.py
@@ -223,6 +223,8 @@ class Bundler:
         for path in binaries:
             if os.path.islink(path.source):
                 continue
+            if (path.compute_destination(self.project) in self.binary_paths):
+                continue
             dest = path.copy_target(self.project)
             self.binary_paths.append(dest)
             # Clean out any libtool (*.la) files and static libraries
diff --git a/bundler/project.py b/bundler/project.py
index d9e4548..1711e65 100644
--- a/bundler/project.py
+++ b/bundler/project.py
@@ -99,7 +99,7 @@ class Path(object):
         except EnvironmentError as e:
             if e.errno == errno.ENOENT:
                 print("Warning, source file missing: " + source)
-            elif e.errno == errno.EEXIST:
+            elif e.errno in (errno.EEXIST, errno.EACCES):
                 print("Warning, path already exits: " + dest)
             else:
                 raise EnvironmentError("Error %s when copying file: %s"
@@ -129,10 +129,7 @@ class Path(object):
                 else:
                     self.copy_file(globbed_source, dest)
 
-    # Copies from source to dest, evaluating any variables
-    # in the paths, and returns the real dest.
-    def copy_target(self, project):
-        source = project.evaluate_path(self.source)
+    def compute_destination(self, project):
         if self.dest:
             dest = project.evaluate_path(self.dest)
         else:
@@ -147,10 +144,20 @@ class Path(object):
             else:
                 raise ValueError ("Invalid path, missing or invalid dest %s."
                                   % self.dest)
-
+        # If the destination has a wildcard as last component (copied
+        # from the source in dest-less paths), ignore the tail.
         (dest_parent, dest_tail) = os.path.split(dest)
+        p = re.compile("[\*\?]")
+        if p.search(dest_tail):
+            dest = dest_parent
+
         utils.makedirs(dest_parent)
+        return dest
 
+    # Copies from source to dest, evaluating any variables
+    # in the paths, and returns the real dest.
+    def copy_target(self, project):
+        source = project.evaluate_path(self.source)
         # Check that the source only has wildcards in the last component.
         p = re.compile("[\*\?]")
         (source_parent, source_tail) = os.path.split(source)
@@ -165,10 +172,7 @@ class Path(object):
         if not os.path.exists(source_check):
             raise ValueError("Cannot find source to copy: " + source)
 
-        # If the destination has a wildcard as last component (copied
-        # from the source in dest-less paths), ignore the tail.
-        if p.search(dest_tail):
-            dest = dest_parent
+        dest = self.compute_destination(project)
 
         if self.recurse:
             self.copy_target_glob_recursive(source, dest)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]