Skip to content

Commit

Permalink
crashrecovery: reduce i/o by scoping find
Browse files Browse the repository at this point in the history
Closes #345
  • Loading branch information
graysky2 committed May 25, 2024
1 parent 96838cf commit 9491a03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = 6.50
VERSION = 6.51
PN = profile-sync-daemon

PREFIX ?= /usr
Expand Down
6 changes: 3 additions & 3 deletions common/profile-sync-daemon.in
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ cleanup() {
local CRASHArr=()
while IFS= read -d '' -r backup; do
CRASHArr=("${CRASHArr[@]}" "$backup")
done < <(find "${DIR%/*}" -type d -name '*crashrecovery*' -print0 | sort -r -z)
done < <(find "${DIR%/*}" -maxdepth 1 -type d -name "${DIR##*/}-backup-crashrecovery-*" -print0 | sort -r -z)

if [[ ${#CRASHArr[@]} -gt 0 ]]; then
echo -e "${BLD}Deleting ${#CRASHArr[@]} crashrecovery dir(s) for profile ${BLU}$DIR${NRM}"
Expand Down Expand Up @@ -590,7 +590,7 @@ enforce() {
local CRASHArr=()
while IFS= read -d '' -r backup; do
CRASHArr=("${CRASHArr[@]}" "$backup")
done < <(find "${DIR%/*}" -type d -name '*crashrecovery*' -print0 | sort -r -z)
done < <(find "${DIR%/*}" -maxdepth 1 -type d -name "${DIR##*/}-backup-crashrecovery-*" -print0 | sort -r -z)

if [[ ${#CRASHArr[@]} -gt $BACKUP_LIMIT ]]; then
for remove in "${CRASHArr[@]:$BACKUP_LIMIT}"; do
Expand Down Expand Up @@ -686,7 +686,7 @@ parse() {
local CRASHArr=()
while IFS= read -d '' -r backup; do
CRASHArr=("${CRASHArr[@]}" "$backup")
done < <(find "${DIR%/*}" -type d -name '*crashrecovery*' -print0 | sort -r -z)
done < <(find "${DIR%/*}" -maxdepth 1 -type d -name "${DIR##*/}-backup-crashrecovery-*" -print0 | sort -r -z)

# get permissions on profile dir and be smart about it since symlinks are all 777
[[ -f $PID_FILE ]] && TRUEP=$(stat -c %a "$BACKUP") || TRUEP=$(stat -c %a "$DIR")
Expand Down

0 comments on commit 9491a03

Please sign in to comment.