File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments