From 7137ddeda868e60505e26e8c7da6b2999402208a Mon Sep 17 00:00:00 2001
From: Philippe PITTOLI
Date: Fri, 17 Apr 2020 12:04:55 +0200
Subject: [PATCH] Script to verify the DB consistency.
---
utils/verify-db-consistency.sh | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100755 utils/verify-db-consistency.sh
diff --git a/utils/verify-db-consistency.sh b/utils/verify-db-consistency.sh
new file mode 100755
index 0000000..87dd7f6
--- /dev/null
+++ b/utils/verify-db-consistency.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/zsh
+
+if [ $# -ne 1 ] || [ $1 = "-h" ]
+then
+ echo "usage: $0 todod-storage"
+ exit 0
+fi
+
+storage=$1
+
+echo "verify the list-tasks relation: list have tasks, these tasks must exists"
+for list in ${storage}/data/lists/indices/by_id/*
+do
+ echo "list: $list"
+ # echo "Tasks:"
+ cat $list | jq -r ".tasks[]" | while read task
+ do
+ ls ${storage}/data/tasks/indices/by_id/$task.json 2>/dev/null 1>/dev/null
+ if [ $? -eq 0 ]
+ then
+ # echo "- task $task"
+ else
+ echo "- task: ${storage}/data/tasks/indices/by_id/$task.json doesn't exist"
+ fi
+ done
+done