Browse Source

sync: minimise process spawning

Signed-off-by: Alejandro Mery <amery@geeks.cl>
master
Alejandro Mery 3 years ago
parent
commit
7f1bf39549
2 changed files with 15 additions and 6 deletions
  1. +2
    -4
      sync.sh
  2. +13
    -2
      sync2.sh

+ 2
- 4
sync.sh

@ -2,9 +2,7 @@
set -e
cd "$(dirname "$0")"
DIR="$PWD"
cd "files"
find ! -type d -exec "$DIR/sync2.sh" '{}' \;
find -H files -print0 | xargs -r0 "$PWD/sync2.sh" -d "files"
exec "$DIR/sync_ssh.sh"
exec "$PWD/sync_ssh.sh"

+ 13
- 2
sync2.sh

@ -5,12 +5,23 @@ err() { echo "E: $$: $*" >&2; }
set -u
FILES="$(pwd -P)"
if [ "x-d" = "x${1:-}" ]; then
BASE="$2"
shift 2
else
BASE=.
fi
FILES="$(readlink -f "$BASE")"
for x; do
# clean
#
x="${x#./}"
case "$x" in
"$BASE") continue ;;
"$BASE"/*) x="${x#$BASE/}" ;;
./*) x="${x#./}" ;;
esac
# find target (d1)
#

Loading…
Cancel
Save