From 3b2d6fd55b0494e2e9312ffc5aa32785f9bdc2b0 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Tue, 9 Apr 2019 00:14:02 +0800 Subject: [PATCH] Handle case when same hash and path appears in both adds and removes --- SongSync.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/SongSync.sh b/SongSync.sh index 54868e2..afe993b 100755 --- a/SongSync.sh +++ b/SongSync.sh @@ -52,6 +52,13 @@ if [ "$1" = "apply" ]; then echo "More than one SM file in ${path}, aborting" exit fi + + if [ "${removes[${path}]}" = "$hash" ]; then + echo "Same hash ($hash) and path ($path) in adds and removes. Ignoring." + unset removes["$hash"] + continue + fi + adds["${path}"]+="$hash" fi @@ -65,6 +72,12 @@ if [ "$1" = "apply" ]; then # I suppose it could happen that one of these borked paths were moved to a different location, but # in that case thered be multiple sms in the adds path. So... I guess its OK. if [ -z "${removes[${path}]}" ]; then + if [ "${adds[${path}]}" = "$hash" ]; then + echo "Same hash ($hash) and path ($path) in adds and removes. Ignoring." + unset adds["$hash"] + continue + fi + removes["${path}"]+="$hash" fi fi -- 2.11.0