cb60cfc7bdc7745dd48afe265df3a13f9cd3e54d

Author
Ariel Rivas <arielcrivas@gmail.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Avoid unnecesary processing... (#5352)

by discarding directories or files with permissions already correctly set

Diff

 1diff --git a/plugins/perms/perms.plugin.zsh b/plugins/perms/perms.plugin.zsh
 2index 81f56d577f7812c103bb383b8c8574b0a2f82607..7cdebab7f792e598241c7863954d79259adca62f 100644
 3--- a/plugins/perms/perms.plugin.zsh
 4+++ b/plugins/perms/perms.plugin.zsh
 5@@ -6,10 +6,10 @@
 6 ### Aliases
 7 
 8 # Set all files' permissions to 644 recursively in a directory
 9-alias set644='find . -type f -print0 | xargs -0 chmod 644'
10+alias set644='find . -type f ! -perm 644 -print0 | xargs -0 chmod 644'
11 
12 # Set all directories' permissions to 755 recursively in a directory
13-alias set755='find . -type d -print0 | xargs -0 chmod 755'
14+alias set755='find . -type d ! -perm 755 -print0 | xargs -0 chmod 755'
15 
16 ### Functions
17 
18@@ -63,14 +63,14 @@ EOF
19   exit_status=0;
20   if [[ $use_slow == true ]]; then
21     # Process directories first so non-traversable ones are fixed as we go
22-    find "$target" -type d -exec chmod $chmod_opts 755 {} \;
23+    find "$target" -type d ! -perm 755 -exec chmod $chmod_opts 755 {} \;
24     if [[ $? != 0 ]]; then exit_status=$?; fi
25-    find "$target" -type f -exec chmod $chmod_opts 644 {} \;
26+    find "$target" -type f ! -perm 644 -exec chmod $chmod_opts 644 {} \;
27     if [[ $? != 0 ]]; then exit_status=$?; fi
28   else
29-    find "$target" -type d -print0 | xargs -0 chmod $chmod_opts 755
30+    find "$target" -type d ! -perm 755 -print0 | xargs -0 chmod $chmod_opts 755
31     if [[ $? != 0 ]]; then exit_status=$?; fi
32-    find "$target" -type f -print0 | xargs -0 chmod $chmod_opts 644
33+    find "$target" -type f ! -perm 644 -print0 | xargs -0 chmod $chmod_opts 644
34     if [[ $? != 0 ]]; then exit_status=$?; fi
35   fi
36   echo "Complete"