Remote deletion returns error when no error has happened

This commit is contained in:
deajan 2018-10-10 20:47:11 +02:00
parent a2e3e96827
commit 4c999ec229
1 changed files with 18 additions and 4 deletions

View File

@ -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=2018101011 PROGRAM_BUILD=2018101012
IS_STABLE=no IS_STABLE=no
##### Execution order #__WITH_PARANOIA_DEBUG ##### Execution order #__WITH_PARANOIA_DEBUG
@ -1257,7 +1257,7 @@ function _deleteLocal {
local deletionDir="${3}" # deletion dir in format .[workdir]/deleted local deletionDir="${3}" # deletion dir in format .[workdir]/deleted
__CheckArguments 3 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 3 $# "$@" #__WITH_PARANOIA_DEBUG
local retval local retval=0
local parentdir local parentdir
local previousFile="" local previousFile=""
@ -1277,7 +1277,7 @@ function _deleteLocal {
retval=$? retval=$?
if [ $retval -ne 0 ]; then if [ $retval -ne 0 ]; then
Logger "Cannot create local replica deletion directory in [$replicaDir$deletionDir]." "ERROR" $retval Logger "Cannot create local replica deletion directory in [$replicaDir$deletionDir]." "ERROR" $retval
exit 1 return $retval
fi fi
fi fi
@ -1288,6 +1288,10 @@ function _deleteLocal {
if [ $_DRYRUN == false ]; then if [ $_DRYRUN == false ]; then
if [ -e "$replicaDir$deletionDir/$files" ] || [ -L "$replicaDir$deletionDir/$files" ]; then if [ -e "$replicaDir$deletionDir/$files" ] || [ -L "$replicaDir$deletionDir/$files" ]; then
rm -rf "${replicaDir:?}$deletionDir/$files" rm -rf "${replicaDir:?}$deletionDir/$files"
if [ $? -ne 0 ]; then
Logger "Cannot remove [${replicaDir:?}$deletionDir/$files]." "ERROR"
retval=1
fi
fi fi
if [ -e "$replicaDir$files" ] || [ -L "$replicaDir$files" ]; then if [ -e "$replicaDir$files" ] || [ -L "$replicaDir$files" ]; then
@ -1328,6 +1332,7 @@ function _deleteLocal {
previousFile="$files" previousFile="$files"
fi fi
done < "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$deletionListFromReplica${INITIATOR[$__deletedListFile]}" done < "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/$deletionListFromReplica${INITIATOR[$__deletedListFile]}"
return $retval
} }
function _deleteRemote { function _deleteRemote {
@ -1388,6 +1393,7 @@ include #### TrapError SUBSET ####
include #### RemoteLogger SUBSET #### include #### RemoteLogger SUBSET ####
include #### CleanUp SUBSET #### include #### CleanUp SUBSET ####
function _deleteRemoteSub {
## Empty earlier failed delete list ## Empty earlier failed delete list
> "$FAILED_DELETE_LIST" > "$FAILED_DELETE_LIST"
> "$SUCCESS_DELETE_LIST" > "$SUCCESS_DELETE_LIST"
@ -1412,6 +1418,10 @@ include #### CleanUp SUBSET ####
if [ $_DRYRUN == false ]; then if [ $_DRYRUN == false ]; then
if [ -e "$REPLICA_DIR$DELETION_DIR/$files" ] || [ -L "$REPLICA_DIR$DELETION_DIR/$files" ]; then if [ -e "$REPLICA_DIR$DELETION_DIR/$files" ] || [ -L "$REPLICA_DIR$DELETION_DIR/$files" ]; then
rm -rf "$REPLICA_DIR$DELETION_DIR/$files" rm -rf "$REPLICA_DIR$DELETION_DIR/$files"
if [ $? -ne 0 ]; then
RemoteLogger "Cannot remove [$REPLICA_DIR$DELETION_DIR/$files]." "ERROR"
retval=1
fi
fi fi
if [ -e "$REPLICA_DIR$files" ] || [ -L "$REPLICA_DIR$files" ]; then if [ -e "$REPLICA_DIR$files" ] || [ -L "$REPLICA_DIR$files" ]; then
@ -1453,11 +1463,15 @@ include #### CleanUp SUBSET ####
previousFile="$files" previousFile="$files"
fi fi
done < "$FILE_LIST" done < "$FILE_LIST"
return $retval
}
_deleteRemoteSub
CleanUp CleanUp
exit $retval
ENDSSH ENDSSH
if [ -s "$RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP" ]; then if [ -s "$RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP" ] && [ $retval -ne 0 ]; then
( (
_LOGGER_PREFIX="RR" _LOGGER_PREFIX="RR"
Logger "$(cat $RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP)" "ERROR" Logger "$(cat $RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP)" "ERROR"