Replaced 0/1 with bolean logic
This commit is contained in:
parent
472e5e2251
commit
2764930dc4
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#TODO(critical): handle conflict prevalance, especially in sync_attrs function
|
#TODO(critical): handle conflict prevalance, especially in sync_attrs function
|
||||||
#TODO(ciritcal): deleted file has "deleted" name in target
|
|
||||||
#TODO(high): verbose mode doesn't show files to be softdeleted
|
#TODO(high): verbose mode doesn't show files to be softdeleted
|
||||||
|
#TODO(medium): No remote deletion dir when del dir is present
|
||||||
|
|
||||||
PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
|
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"
|
||||||
|
@ -932,15 +932,12 @@ function _delete_local {
|
||||||
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" != "$previous_file/"* ]] && [ "$files" != "" ]; then
|
if [[ "$files" != "$previous_file/"* ]] && [ "$files" != "" ]; then
|
||||||
if [ $_VERBOSE == true ]; then
|
|
||||||
Logger "Soft deleting $replica_dir$files" "NOTICE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
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" ]; then
|
||||||
rm -rf "${replica_dir:?}$deletion_dir/$files"
|
rm -rf "${replica_dir:?}$deletion_dir/$files"
|
||||||
Logger "Deleting file [$replica_dir$files]." "DEBUG"
|
Logger "Deleting file [$replica_dir$files]." "VERBOSE"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -949,11 +946,11 @@ function _delete_local {
|
||||||
parentdir="$(dirname "$files")"
|
parentdir="$(dirname "$files")"
|
||||||
if [ "$parentdir" != "." ]; then
|
if [ "$parentdir" != "." ]; then
|
||||||
mkdir -p "$replica_dir$deletion_dir/$parentdir"
|
mkdir -p "$replica_dir$deletion_dir/$parentdir"
|
||||||
Logger "Moving deleted file [$replica_dir$files] to [$replica_dir$deletion_dir/$parentdir]." "DEBUG"
|
Logger "Moving deleted file [$replica_dir$files] to [$replica_dir$deletion_dir/$parentdir]." "VERBOSE"
|
||||||
mv -f "$replica_dir$files" "$replica_dir$deletion_dir/$parentdir"
|
mv -f "$replica_dir$files" "$replica_dir$deletion_dir/$parentdir"
|
||||||
else
|
else
|
||||||
|
Logger "Moving deleted file [$replica_dir$files] to [$replica_dir$deletion_dir]." "VERBOSE"
|
||||||
mv -f "$replica_dir$files" "$replica_dir$deletion_dir"
|
mv -f "$replica_dir$files" "$replica_dir$deletion_dir"
|
||||||
Logger "Moving deleted file [$replica_dir$files] to [$replica_dir$deletion_dir]." "DEBUG"
|
|
||||||
fi
|
fi
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot move [$replica_dir$files] to deletion directory." "ERROR"
|
Logger "Cannot move [$replica_dir$files] to deletion directory." "ERROR"
|
||||||
|
@ -1059,15 +1056,12 @@ $SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _SILENT=$_SILENT _DEBUG=
|
||||||
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" != "$previous_file/"* ]] && [ "$files" != "" ]; then
|
if [[ "$files" != "$previous_file/"* ]] && [ "$files" != "" ]; then
|
||||||
if [ $_VERBOSE == true ]; then
|
|
||||||
Logger "Soft deleting $REPLICA_DIR$files" "NOTICE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$SOFT_DELETE" != "no" ]; then
|
if [ "$SOFT_DELETE" != "no" ]; then
|
||||||
if [ $_DRYRUN == false ]; then
|
if [ $_DRYRUN == false ]; then
|
||||||
if [ -e "$REPLICA_DIR$DELETE_DIR/$files" ]; then
|
if [ -e "$REPLICA_DIR$DELETE_DIR/$files" ]; then
|
||||||
$COMMAND_SUDO rm -rf "$REPLICA_DIR$DELETE_DIR/$files"
|
$COMMAND_SUDO rm -rf "$REPLICA_DIR$DELETE_DIR/$files"
|
||||||
Logger "Deleting file [$REPLICA_DIR$files]." "DEBUG"
|
Logger "Deleting file [$REPLICA_DIR$files]." "VERBOSE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$REPLICA_DIR$files" ]; then
|
if [ -e "$REPLICA_DIR$files" ]; then
|
||||||
|
@ -1076,10 +1070,10 @@ $SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _SILENT=$_SILENT _DEBUG=
|
||||||
if [ "$parentdir" != "." ]; then
|
if [ "$parentdir" != "." ]; then
|
||||||
$COMMAND_SUDO mkdir -p "$REPLICA_DIR$DELETE_DIR/$parentdir"
|
$COMMAND_SUDO mkdir -p "$REPLICA_DIR$DELETE_DIR/$parentdir"
|
||||||
$COMMAND_SUDO mv -f "$REPLICA_DIR$files" "$REPLICA_DIR$DELETE_DIR/$parentdir"
|
$COMMAND_SUDO mv -f "$REPLICA_DIR$files" "$REPLICA_DIR$DELETE_DIR/$parentdir"
|
||||||
Logger "Moving deleted file [$REPLICA_DIR$files] to [$REPLICA_DIR$DELETE_DIR/$parentdir]." "DEBUG"
|
Logger "Moving deleted file [$REPLICA_DIR$files] to [$REPLICA_DIR$DELETE_DIR/$parentdir]." "VERBOSE"
|
||||||
else
|
else
|
||||||
$COMMAND_SUDO mv -f "$REPLICA_DIR$files" "$REPLICA_DIR$DELETE_DIR"
|
$COMMAND_SUDO mv -f "$REPLICA_DIR$files" "$REPLICA_DIR$DELETE_DIR"
|
||||||
Logger "Moving deleted file [$REPLICA_DIR$files] to [$REPLICA_DIR$DELETE_DIR]." "DEBUG"
|
Logger "Moving deleted file [$REPLICA_DIR$files] to [$REPLICA_DIR$DELETE_DIR]." "VERBOSE"
|
||||||
fi
|
fi
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot move [$REPLICA_DIR$files] to deletion directory." "ERROR"
|
Logger "Cannot move [$REPLICA_DIR$files] to deletion directory." "ERROR"
|
||||||
|
|
|
@ -110,7 +110,11 @@ function _Logger {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# General log function with log levels
|
# General log function with log levels:
|
||||||
|
# CRITICAL, ERROR, WARN are colored in stdout, prefixed in stderr
|
||||||
|
# NOTICE is standard level
|
||||||
|
# VERBOSE is only sent to stdout / stderr if _VERBOSE=true
|
||||||
|
# DEBUG & PARANOIA_DEBUG are only sent if _DEBUG=yes
|
||||||
function Logger {
|
function Logger {
|
||||||
local value="${1}" # Sentence to log (in double quotes)
|
local value="${1}" # Sentence to log (in double quotes)
|
||||||
local level="${2}" # Log level: PARANOIA_DEBUG, DEBUG, VERBOSE, NOTICE, WARN, ERROR, CRITIAL
|
local level="${2}" # Log level: PARANOIA_DEBUG, DEBUG, VERBOSE, NOTICE, WARN, ERROR, CRITIAL
|
||||||
|
|
Loading…
Reference in New Issue