diff options
author | Aleksei Vetrov <vvvvvv@google.com> | 2023-02-09 18:42:38 +0000 |
---|---|---|
committer | Aleksei Vetrov <vvvvvv@google.com> | 2023-02-09 18:54:44 +0000 |
commit | 85a9fe7a10d86ca134636a3b103221ff509d07f6 (patch) | |
tree | f662b7d90c60f5759bba575cfae40277ed76e458 | |
parent | 462dcdcccb0595260aa3b51b8dab302182a58307 (diff) | |
download | bazel_common_rules-85a9fe7a10d86ca134636a3b103221ff509d07f6.tar.gz |
Allow overwrite of directories in copy_to_dist_dir
If we would like to run _dist tasks twice, we have to allow overwriting
files inside directories. It is enough to make directory writable before
copying its contents, which allows removal of the files inside. Then
shutil.copytree will restore correct permissions through the copystat.
Test: TH
Bug: 267607344
Change-Id: I11f8e330c06d71ef1a1b674f846f70bd1bbb1931
-rw-r--r-- | dist/dist.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/dist/dist.py b/dist/dist.py index 4579a11..c9f7be9 100644 --- a/dist/dist.py +++ b/dist/dist.py @@ -122,6 +122,10 @@ def copy_files_to_dist_dir(files, archives, mode_overrides, dist_dir, flat, pref copy_with_modes(src, dst, mode_overrides) elif os.path.isdir(src): logging.debug("Copying dir: %s" % dst) + if os.path.exists(dst): + # make the directory temporary writable, then + # shutil.copytree will restore correct permissions. + os.chmod(dst, 750) shutil.copytree( os.path.abspath(src), dst, |