From 82ff38ba326ef6ecf3830e7d667b5c7510875ce1 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Thu, 10 Feb 2022 08:04:36 -0700 Subject: [PATCH] change notes.put to args for newlines --- app/crawler/notes.sh | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/app/crawler/notes.sh b/app/crawler/notes.sh index 0644548..0972ba8 100644 --- a/app/crawler/notes.sh +++ b/app/crawler/notes.sh @@ -6,11 +6,7 @@ notes() ( } _tree() { - local cache_key="notes cache _tree" - if cache get "$cache_key"; then - return 0 - fi - __tree "$@" | cache put "$cache_key" + __tree "$@" } __tree() { @@ -27,7 +23,7 @@ notes() ( if echo "$json" | jq .Branches | grep -q ^null$; then return 0 fi - local b64lines="$(echo "$json" | jq -r '.Branches | keys[]' | base64)" + local b64lines="$(echo "$json" | jq -r '.Branches | keys[]' | while read -r line; do echo "$line" | base64; done)" if [ -z "$b64lines" ]; then return 0 fi @@ -38,14 +34,17 @@ notes() ( if ! _is_deleted "$subfix"; then echo "$subfix" fi - _recurse_ids "$subfix" "$(echo "$json" | jq ".Branches.$line")" + _recurse_ids "$subfix" "$(echo "$json" | jq -c ".Branches[\"$line\"]")" done } meta() { local id="$1" - id="${id//\//.Branches.}" - _tree | jq -c ".Branches.$id.Leaf" + local tree="$(_tree)" + for subid in ${id//\// }; do + tree="$(echo "$tree" | jq -c .Branches | jq -c ".[\"$subid\"]")" + done + echo "$tree" | jq .Leaf } _is_deleted() { @@ -63,11 +62,7 @@ notes() ( } get() { - local cache_key="notes cache $1" - if cache get "$cache_key"; then - return 0 - fi - _get "$@" | cache put "$cache_key" + _get "$@" } _get() { @@ -91,7 +86,7 @@ notes() ( echo "$body" | _nncurl \ -X PUT \ -H "Title: $title" \ - -d @- \ + -d "$body" \ $NOTES_ADDR/api/v0/files/$id }