Stability fixes. If no notes are present the README file is copied over as a note, this causes dialog to not fail on menu generation. If the README isn't found, it creates a message in a file called README.md.

This commit is contained in:
Storm Dragon
2019-08-03 13:24:44 -04:00
parent eddb54e503
commit 74c0d402d5

View File

@@ -188,6 +188,21 @@ encrypt_note() {
infobox "$(gettext "Encryption failed.")"
}
original_note() {
# If no notes are present this will try to copy the README.md file into the notes directory so the menu won't fail.
mapfile -t notes < <(find "$xdgPath/notestorm/notes" -type f -iname '*.md' -o -iname '*.gpg')
if [[ "${#notes[@]}" -gt 0 ]]; then
return
fi
if [[ -f "README.md" ]]; then
cp "README.md" "${xdgPath}/notestorm/notes/README.md"
elif [[ -f "/usr/share/doc/notestorm/README.md" ]]; then
cp "README.md" "${xdgPath}/notestorm/notes/README.md"
else
echo "The README file is missing. Pleae visit the notestorm git page for usage information." > "${xdgPath}/notestorm/notes/README.md"
fi
}
# Configuration section
# Available arguments in both long and short versions stored in associative array.
declare -A argList=(
@@ -210,8 +225,9 @@ else
pager="${PAGER:-more}"
fi
xdgPath="${XDG_CONFIG_HOME:-$HOME/.config}"
#set up the notes directory
# set up the notes directory
mkdir -p "${xdgPath}/notestorm/notes"
original_note
# Keep track of the number of arguments passed to the program.
argNum=$#
# Settings to improve accessibility of dialog.