Bug 920637 - FileCopier should create destination directory if it doesn't exist; r=glandium
authorGregory Szorc <gps@mozilla.com>
Fri, 04 Oct 2013 15:00:39 +0200
changeset 149907 74c262c73ebbc65a38785d17734bd4fff36816ba
parent 149906 23b80710852432518d6bcc29ccafab7247a3fd19
child 149908 b222d20212b3319bb2daa915b44c9c72a35235e3
push id25405
push userphilringnalda@gmail.com
push dateSat, 05 Oct 2013 05:04:31 +0000
treeherdermozilla-central@bd7bb523c5dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs920637
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 920637 - FileCopier should create destination directory if it doesn't exist; r=glandium
python/mozbuild/mozpack/copier.py
--- a/python/mozbuild/mozpack/copier.py
+++ b/python/mozbuild/mozpack/copier.py
@@ -164,16 +164,27 @@ class FileCopier(FileRegistry):
         '''
         assert isinstance(destination, basestring)
         assert not os.path.exists(destination) or os.path.isdir(destination)
 
         result = FileCopyResult()
         have_symlinks = hasattr(os, 'symlink')
         destination = os.path.normpath(destination)
 
+        # We create the destination directory specially. We can't do this as
+        # part of the loop doing mkdir() below because that loop munges
+        # symlinks and permissions and parent directories of the destination
+        # directory may have their own weird schema. The contract is we only
+        # manage children of destination, not its parents.
+        try:
+            os.makedirs(destination)
+        except OSError as e:
+            if e.errno != errno.EEXIST:
+                raise
+
         # Because we could be handling thousands of files, code in this
         # function is optimized to minimize system calls. We prefer CPU time
         # in Python over possibly I/O bound filesystem calls to stat() and
         # friends.
 
         required_dirs = set()
         dest_files = set()