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:
18
notestorm
18
notestorm
@@ -188,6 +188,21 @@ encrypt_note() {
|
|||||||
infobox "$(gettext "Encryption failed.")"
|
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
|
# Configuration section
|
||||||
# Available arguments in both long and short versions stored in associative array.
|
# Available arguments in both long and short versions stored in associative array.
|
||||||
declare -A argList=(
|
declare -A argList=(
|
||||||
@@ -210,8 +225,9 @@ else
|
|||||||
pager="${PAGER:-more}"
|
pager="${PAGER:-more}"
|
||||||
fi
|
fi
|
||||||
xdgPath="${XDG_CONFIG_HOME:-$HOME/.config}"
|
xdgPath="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
#set up the notes directory
|
# set up the notes directory
|
||||||
mkdir -p "${xdgPath}/notestorm/notes"
|
mkdir -p "${xdgPath}/notestorm/notes"
|
||||||
|
original_note
|
||||||
# Keep track of the number of arguments passed to the program.
|
# Keep track of the number of arguments passed to the program.
|
||||||
argNum=$#
|
argNum=$#
|
||||||
# Settings to improve accessibility of dialog.
|
# Settings to improve accessibility of dialog.
|
||||||
|
|||||||
Reference in New Issue
Block a user