From 6729906e5acdc14f0e904d855df850a54f5b5496 Mon Sep 17 00:00:00 2001 From: Amber Date: Sat, 5 Nov 2022 11:26:51 +0100 Subject: [PATCH] better comments --- masync | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/masync b/masync index f70d2ca..e33a028 100755 --- a/masync +++ b/masync @@ -125,8 +125,20 @@ initsyncpath() { } +########################################## +# the start action is composed by +# 1. Checking the presence of the snapshot. +# Snapshot indicates the files present in origin (and in local path) when the sync was stopped +# if the snapshot is present we MUST check if all file in the snapshot are still present +# in origin. If not we must remove it from local folder feeding the deletes +# +# 2. Pushing a dummmy action into the queue to force an rsync from local folder to remote, +# For eventually new files +# 3. starting the loop listening for the changes in local folder +########################################## + startsyncpath() { - echo -e "Starting mirror local folder ${GREEN}$1${ENDCOLOR} with remote ${GREEN}$2${ENDCOLOR}..." + echo -e "Start synching local folder ${GREEN}$1${ENDCOLOR} with remote ${GREEN}$2${ENDCOLOR}..." localpath_hash=$(echo "$1" | md5sum | cut -f1 --delimiter=" " -) snapshotfile=${SNAPSHOTFILE}${localpath_hash} tempqueuefile=~/.syncdir_${localpath_hash}.queue @@ -139,7 +151,7 @@ startsyncpath() { fi ## ensure local computer sends eventually new files adding a fake line in the queue echo "Startsync DUMMY ACTION" >> ${tempqueuefile} - echo -e "Mirrorring ${GREEN}DONE${ENDCOLOR}" + echo -e "${GREEN}DONE${ENDCOLOR}" loopsyncpath $1 } @@ -147,6 +159,14 @@ readlog() { tail -f ~/syncloop_$1.nohup } +########################################## +# start the loop for synching local folder with remote folder. +# You can use as first argument the integer of sync or the local path. +# It spawn in background `syncloop.sh` and redirect stamdard output +# and standard error on syncloop_$hash.nohup +# +########################################## + loopsyncpath() { echo -e "Starting loop for synching ${GREEN}$1${ENDCOLOR}" re_num='^[0-9]+$'