Skip to content

Commit cc59923

Browse files
committed
Only attempt chgrp/chmod if necessary
1 parent 971ce47 commit cc59923

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

run_release.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,18 @@ def execute_command(command: str) -> None:
812812
def copy_and_set_permissions(source_glob: str, destination: str) -> None:
813813
execute_command(f"mkdir -p {destination}")
814814
execute_command(f"cp {source_glob} {destination}")
815-
execute_command(f"chgrp downloads {destination}")
816-
execute_command(f"chmod 775 {destination}")
817-
execute_command(f"find {destination} -type f -exec chmod 664 {{}} \\;")
815+
# Skip chgrp/chmod if already correct: another RM may have created
816+
# the directory, and only the owner can change group or permissions.
817+
execute_command(
818+
f"find {destination} -maxdepth 0 ! -group downloads "
819+
f"-exec chgrp downloads {{}} +"
820+
)
821+
execute_command(
822+
f"find {destination} -maxdepth 0 ! -perm 775 -exec chmod 775 {{}} +"
823+
)
824+
execute_command(
825+
f"find {destination} -type f ! -perm 664 -exec chmod 664 {{}} +"
826+
)
818827

819828
copy_and_set_permissions(f"{source}/downloads/*", destination)
820829

0 commit comments

Comments
 (0)