From 1499f7f1ebeac736b937f39aee732ca146451f00 Mon Sep 17 00:00:00 2001 From: Guiorgy Date: Wed, 7 Feb 2024 18:22:21 +0400 Subject: [PATCH 1/3] print error and exit if file can't be opened during import --- vackup | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) mode change 100755 => 100644 vackup diff --git a/vackup b/vackup old mode 100755 new mode 100644 index 168a963..a980f83 --- a/vackup +++ b/vackup @@ -91,7 +91,12 @@ cmd_import() { usage exit 1 fi - + + if [ ! -r "$FILE_NAME" ]; then + echo "Error: Could not find or open tar file $FILE_NAME" + exit 1 + fi + if ! docker volume inspect --format '{{.Name}}' "$VOLUME_NAME"; then echo "Error: Volume $VOLUME_NAME does not exist" From 185ffb4fa5cf5569975048f6516f06d38103eb6e Mon Sep 17 00:00:00 2001 From: Guiorgy Date: Thu, 8 Feb 2024 17:20:48 +0400 Subject: [PATCH 2/3] removed todo --- vackup | 2 -- 1 file changed, 2 deletions(-) diff --git a/vackup b/vackup index a980f83..6e08486 100644 --- a/vackup +++ b/vackup @@ -103,8 +103,6 @@ cmd_import() { docker volume create "$VOLUME_NAME" fi -# TODO: check if file exists on host, if it does -# create a option for overwrite and check if that's set # TODO: if FILE_NAME starts with / we need to error out # unless we can translate full file paths From 3bc0234921c52572e2e5e1e71d5caf76960cf423 Mon Sep 17 00:00:00 2001 From: Guiorgy Date: Fri, 9 Feb 2024 15:24:19 +0400 Subject: [PATCH 3/3] print error and exit if FILE_NAME is a directory --- vackup | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vackup b/vackup index 6e08486..2e17404 100644 --- a/vackup +++ b/vackup @@ -97,6 +97,11 @@ cmd_import() { exit 1 fi + if [ -d "$FILE_NAME" ]; then + echo "Error: $FILE_NAME is a directory" + exit 1 + fi + if ! docker volume inspect --format '{{.Name}}' "$VOLUME_NAME"; then echo "Error: Volume $VOLUME_NAME does not exist"