Skip to content

Commit 624e8ac

Browse files
authored
clean rm of copied dirs and files (#799)
1 parent fea9515 commit 624e8ac

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/private/write_source_file.bzl

+4
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ out={out_path}
219219
mkdir -p "$(dirname "$out")"
220220
if [[ -f "$in" ]]; then
221221
echo "Copying file $in to $out in $PWD"
222+
# in case `cp` from previous command was terminated midway which can result in read-only files/dirs
223+
chmod -R ug+w "$out" > /dev/null 2>&1 || true
222224
rm -Rf "$out"
223225
cp -f "$in" "$out"
224226
# cp should make the file writable but call chmod anyway as a defense in depth
@@ -227,6 +229,8 @@ if [[ -f "$in" ]]; then
227229
{executable_file}
228230
else
229231
echo "Copying directory $in to $out in $PWD"
232+
# in case `cp` from previous command was terminated midway which can result in read-only files/dirs
233+
chmod -R ug+w "$out" > /dev/null 2>&1 || true
230234
rm -Rf "$out"/*
231235
mkdir -p "$out"
232236
cp -fRL "$in"/* "$out"

0 commit comments

Comments
 (0)