Litte performance improvement by not running code again
This commit is contained in:
parent
dfe09f2fa3
commit
83cfabed6f
|
@ -9,7 +9,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
|
||||||
AUTHOR="(C) 2013-2018 by Orsiris de Jong"
|
AUTHOR="(C) 2013-2018 by Orsiris de Jong"
|
||||||
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=1.3.0-beta1
|
PROGRAM_VERSION=1.3.0-beta1
|
||||||
PROGRAM_BUILD=2018101008
|
PROGRAM_BUILD=2018101009
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
##### Execution order #__WITH_PARANOIA_DEBUG
|
##### Execution order #__WITH_PARANOIA_DEBUG
|
||||||
|
@ -2716,7 +2716,7 @@ function SyncOnChanges {
|
||||||
__CheckArguments 1 $# "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 1 $# "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
local watchDirectory
|
local watchDirectory
|
||||||
local cmd
|
local initiatorWatchCmd
|
||||||
local retval
|
local retval
|
||||||
|
|
||||||
if [ "$LOCAL_OS" == "MacOSX" ]; then
|
if [ "$LOCAL_OS" == "MacOSX" ]; then
|
||||||
|
@ -2736,35 +2736,34 @@ function SyncOnChanges {
|
||||||
Logger "Initiator directory [$INITIATOR_SYNC_DIR] does not exist. Cannot monitor." "CRITICAL"
|
Logger "Initiator directory [$INITIATOR_SYNC_DIR] does not exist. Cannot monitor." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
watchDirectory="$INITIATOR_SYNC_DIR"
|
||||||
|
if [ "$ConfigFile" != "" ]; then
|
||||||
|
initiatorWatchCmd='bash '$osync_cmd' "'$ConfigFile'" '$opts
|
||||||
|
else
|
||||||
|
initiatorWatchCmd='bash '$osync_cmd' '$opts
|
||||||
|
fi
|
||||||
Logger "#### Running $PROGRAM in initiator file monitor mode." "NOTICE"
|
Logger "#### Running $PROGRAM in initiator file monitor mode." "NOTICE"
|
||||||
else
|
else
|
||||||
if [ ! -d "$TARGET_SYNC_DIR" ]; then
|
if [ ! -d "$TARGET_SYNC_DIR" ]; then
|
||||||
Logger "Target directory [$TARGET_SYNC_DIR] does not exist. Cannot monitor." "CRITICAL"
|
Logger "Target directory [$TARGET_SYNC_DIR] does not exist. Cannot monitor." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
watchDirectory="$TARGET_SYNC_DIR"
|
||||||
Logger "#### Running $PROGRAM in target helper file monitor mode." "NOTICE"
|
Logger "#### Running $PROGRAM in target helper file monitor mode." "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if [ $isTargetHelper == false ]; then
|
if [ $isTargetHelper == false ]; then
|
||||||
if [ "$ConfigFile" != "" ]; then
|
Logger "Daemon cmd: [$initiatorWatchCmd]" "DEBUG"
|
||||||
cmd='bash '$osync_cmd' "'$ConfigFile'" '$opts
|
eval "$initiatorWatchCmd"
|
||||||
else
|
|
||||||
cmd='bash '$osync_cmd' '$opts
|
|
||||||
fi
|
|
||||||
Logger "Daemon cmd: $cmd" "DEBUG"
|
|
||||||
eval "$cmd"
|
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -ne 0 ] && [ $retval != 2 ]; then
|
if [ $retval -ne 0 ] && [ $retval != 2 ]; then
|
||||||
Logger "$PROGRAM child exited with error." "ERROR" $retval
|
Logger "$PROGRAM child exited with error." "ERROR" $retval
|
||||||
fi
|
fi
|
||||||
|
|
||||||
watchDirectory="$INITIATOR_SYNC_DIR"
|
|
||||||
else
|
else
|
||||||
# Notify initiator about target changes
|
# Notify initiator about target changes
|
||||||
|
|
||||||
TriggerInitiatorRun
|
TriggerInitiatorRun
|
||||||
watchDirectory="$TARGET_SYNC_DIR"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue