Index: build/toolchain/mac/copy_bundle_data.py |
diff --git a/build/toolchain/mac/copy_bundle_data.py b/build/toolchain/mac/copy_bundle_data.py |
index 15127a0ce9bfc6a7fb17d9a91f7fc4f9df3c6d7b..f3b29cd110d2c83dde485d36cd638c6654aa6830 100644 |
--- a/build/toolchain/mac/copy_bundle_data.py |
+++ b/build/toolchain/mac/copy_bundle_data.py |
@@ -3,9 +3,11 @@ |
# found in the LICENSE file. |
import argparse |
+import errno |
import os |
import shutil |
import sys |
+import subprocess |
def DetectEncoding(data, default_encoding='UTF-8'): |
@@ -80,25 +82,27 @@ def CopyFile(source, dest, strings_format): |
source: string, path to the source file |
dest: string, path to the destination file |
""" |
- if os.path.isdir(source): |
- if os.path.exists(dest): |
- shutil.rmtree(dest) |
- # Copy tree. |
- # TODO(thakis): This copies file attributes like mtime, while the |
- # single-file branch below doesn't. This should probably be changed to |
- # be consistent with the single-file branch. |
- shutil.copytree(source, dest, symlinks=True) |
- return |
- |
- if os.path.exists(dest): |
- os.unlink(dest) |
+ try: |
+ shutil.rmtree(dest) |
+ except OSError as e: |
+ if e.errno == errno.ENOENT: |
+ pass |
+ elif e.errno == errno.ENOTDIR: |
+ os.unlink(dest) |
+ else: |
+ raise |
_, extension = os.path.splitext(source) |
if extension == '.strings': |
CopyStringsFile(source, dest, strings_format) |
return |
- shutil.copy(source, dest) |
+ # Strip trailing slashes on the source so rsync copies the source as a |
+ # directory. |
+ source = source.rstrip('/') |
+ |
+ subprocess.check_call( |
sdefresne
2016/06/17 17:17:28
I'm not sure this is correct, see my (long) commen
Robert Sesek
2016/06/17 23:11:26
It was not correct. I mixed up how the destination
|
+ ['rsync', '--recursive', '--perms', '--links', source, dest]) |
def Main(): |