Added symlink support in deletion propagation

This commit is contained in:
deajan 2016-12-01 20:51:45 +01:00
parent 33f985b751
commit 651bf48990
1 changed files with 7 additions and 8 deletions

View File

@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong" AUTHOR="(C) 2013-2016 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.2-beta3 PROGRAM_VERSION=1.2-beta3
PROGRAM_BUILD=2016120101 PROGRAM_BUILD=2016120102
IS_STABLE=no IS_STABLE=no
# Execution order #__WITH_PARANOIA_DEBUG # Execution order #__WITH_PARANOIA_DEBUG
@ -1066,14 +1066,13 @@ function _deleteLocal {
while read -r files; do while read -r files; do
## On every run, check wheter the next item is already deleted because it is included in a directory already deleted ## On every run, check wheter the next item is already deleted because it is included in a directory already deleted
if [[ "$files" != "$previousFile/"* ]] && [ "$files" != "" ]; then if [[ "$files" != "$previousFile/"* ]] && [ "$files" != "" ]; then
if [ "$SOFT_DELETE" != "no" ]; then if [ "$SOFT_DELETE" != "no" ]; then
if [ $_DRYRUN == false ]; then if [ $_DRYRUN == false ]; then
if [ -e "$replicaDir$deletionDir/$files" ]; then if [ -e "$replicaDir$deletionDir/$files" ] || [ -L "$replicaDir$deletionDir/$files" ]; then
rm -rf "${replicaDir:?}$deletionDir/$files" rm -rf "${replicaDir:?}$deletionDir/$files"
fi fi
if [ -e "$replicaDir$files" ]; then if [ -e "$replicaDir$files" ] || [ -L "$replicaDir$files" ]; then
# In order to keep full path on soft deletion, create parent directories before move # In order to keep full path on soft deletion, create parent directories before move
parentdir="$(dirname "$files")" parentdir="$(dirname "$files")"
if [ "$parentdir" != "." ]; then if [ "$parentdir" != "." ]; then
@ -1094,7 +1093,7 @@ function _deleteLocal {
fi fi
else else
if [ $_DRYRUN == false ]; then if [ $_DRYRUN == false ]; then
if [ -e "$replicaDir$files" ]; then if [ -e "$replicaDir$files" ] || [ -L "$replicaDir$files" ]; then
rm -rf "$replicaDir$files" rm -rf "$replicaDir$files"
result=$? result=$?
Logger "Deleting [$replicaDir$files]." "VERBOSE" Logger "Deleting [$replicaDir$files]." "VERBOSE"
@ -1219,11 +1218,11 @@ $SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _DEBUG=$_DEBUG _DRYRUN=$
if [ "$SOFT_DELETE" != "no" ]; then if [ "$SOFT_DELETE" != "no" ]; then
if [ $_DRYRUN == false ]; then if [ $_DRYRUN == false ]; then
if [ -e "$REPLICA_DIR$DELETION_DIR/$files" ]; then if [ -e "$REPLICA_DIR$DELETION_DIR/$files" ] || [ -L "$REPLICA_DIR$DELETION_DIR/$files" ]; then
$COMMAND_SUDO rm -rf "$REPLICA_DIR$DELETION_DIR/$files" $COMMAND_SUDO rm -rf "$REPLICA_DIR$DELETION_DIR/$files"
fi fi
if [ -e "$REPLICA_DIR$files" ]; then if [ -e "$REPLICA_DIR$files" ] || [ -L "$REPLICA_DIR$files" ]; then
# In order to keep full path on soft deletion, create parent directories before move # In order to keep full path on soft deletion, create parent directories before move
parentdir="$(dirname "$files")" parentdir="$(dirname "$files")"
if [ "$parentdir" != "." ]; then if [ "$parentdir" != "." ]; then
@ -1245,7 +1244,7 @@ $SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _DEBUG=$_DEBUG _DRYRUN=$
fi fi
else else
if [ $_DRYRUN == false ]; then if [ $_DRYRUN == false ]; then
if [ -e "$REPLICA_DIR$files" ]; then if [ -e "$REPLICA_DIR$files" ] || [ -e "$REPLICA_DIR$files" ]; then
Logger "Deleting [$REPLICA_DIR$files]." "VERBOSE" Logger "Deleting [$REPLICA_DIR$files]." "VERBOSE"
$COMMAND_SUDO rm -rf "$REPLICA_DIR$files" $COMMAND_SUDO rm -rf "$REPLICA_DIR$files"
if [ $? != 0 ]; then if [ $? != 0 ]; then