From 6bf43f3566231005556596d020d57ba72374bcb0 Mon Sep 17 00:00:00 2001 From: "Viktor H. Ingre" Date: Tue, 31 Dec 2024 10:27:44 +0000 Subject: [PATCH 1/2] Fixed bug of not creating new repo dir --- CHANGELOG.md | 3 +++ opt/mirrorsync/.version | 2 +- opt/mirrorsync/mirrorsync.sh | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3da3ceb..7b1478d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Pre-Release 1.0.1-beta (31 December, 2024) +* Minor bug fixes, see #5 + ## Pre-Release 1.0.0-beta (30 December, 2024) * Minor bug fixes * Moved the lockfile creation to the exclude folder to avoid write premission diff --git a/opt/mirrorsync/.version b/opt/mirrorsync/.version index 0aa8850..44b8614 100644 --- a/opt/mirrorsync/.version +++ b/opt/mirrorsync/.version @@ -1 +1 @@ -v1.0.0-beta \ No newline at end of file +v1.0.1-beta \ No newline at end of file diff --git a/opt/mirrorsync/mirrorsync.sh b/opt/mirrorsync/mirrorsync.sh index a3d14ae..5a344d4 100644 --- a/opt/mirrorsync/mirrorsync.sh +++ b/opt/mirrorsync/mirrorsync.sh @@ -274,16 +274,17 @@ do # Define the new path mirrordst="${LOCALDST}/$mirrorname" + # Check if directory exists, else create it + # Validate local path is defined and able to write to if [ -z "$mirrorname" ]; then error "no local directory is defined in \"${repoconfig}\". Continuing with the next mirror" progresscounter=$((progresscounter+3)) continue - elif [ ! -w "$mirrordst" ]; then - error "The path \"${mirrordst}\" is not writable. Continuing with the next mirror" - progresscounter=$((progresscounter+3)) - continue - elif [ ! -d "$mirrordst" ]; then + fi + + # Check if directory exists, else create it + if [ ! -d "$mirrordst" ]; then warning "A local path for \"${mirrorname}\" does not exists, will create one" if [ ! mkdir "$mirrordst" 2>&1 ]; then error "The path \"${mirrordst}\" could not be created. Continuing with the next mirror" @@ -291,6 +292,13 @@ do continue fi fi + + # Validate that the current user can write to this path + if [ ! -w "$mirrordst" ]; then + error "The path \"${mirrordst}\" is not writable. Continuing with the next mirror" + progresscounter=$((progresscounter+3)) + continue + fi # Validate the remotes variable is a array is_array=$(declare -p remotes | grep '^declare -a') From b386d7c6632e892b6db6ec25ba742b9f1c924743 Mon Sep 17 00:00:00 2001 From: "Viktor H. Ingre" Date: Tue, 31 Dec 2024 10:30:12 +0000 Subject: [PATCH 2/2] Cleaned up comments --- opt/mirrorsync/mirrorsync.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/opt/mirrorsync/mirrorsync.sh b/opt/mirrorsync/mirrorsync.sh index 5a344d4..96de9f0 100644 --- a/opt/mirrorsync/mirrorsync.sh +++ b/opt/mirrorsync/mirrorsync.sh @@ -274,8 +274,6 @@ do # Define the new path mirrordst="${LOCALDST}/$mirrorname" - # Check if directory exists, else create it - # Validate local path is defined and able to write to if [ -z "$mirrorname" ]; then error "no local directory is defined in \"${repoconfig}\". Continuing with the next mirror"