Skip to content

Commit

Permalink
feat: check for file existence before en/decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayankur31 committed Apr 28, 2022
1 parent ac1227b commit e7e8f9f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions calliope.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,17 @@ encrypt ()
else
if command -v $GPG_COMMAND %> /dev/null
then
echo "Encrypting $1 with $encryptionId"
$GPG_COMMAND --encrypt --sign -r "$encryptionId" "$1" && rm "$1" -f
if [ -f "$1" ]
then
echo "Encrypting $1 with $encryptionId"
$GPG_COMMAND --encrypt --sign -r "$encryptionId" "$1" && rm "$1" -f
else
echo "File $1 not found"
exit 1
fi
else
echo "$GPG_COMMAND is not installed. Cannot encrypt."
exit 1
fi
fi
}
Expand All @@ -237,11 +244,18 @@ decrypt ()
else
if command -v $GPG_COMMAND %> /dev/null
then
echo "Decrypting $1 with $encryptionId"
nongpgfname="$(basename $1 .gpg)"
$GPG_COMMAND --decrypt $1 > "$nongpgfname"
if [ -f "$1" ]
then
echo "Decrypting $1 with $encryptionId"
nongpgfname="$(basename $1 .gpg)"
$GPG_COMMAND --decrypt $1 > "$nongpgfname"
else
echo "File $1 not found"
exit 1
fi
else
echo "$GPG_COMMAND is not installed. Cannot decrypt."
exit 1
fi
fi
}
Expand Down

0 comments on commit e7e8f9f

Please sign in to comment.