summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-05 22:47:33 +0300
committerPaul Buetow <paul@buetow.org>2026-06-05 22:47:33 +0300
commit1e1287b7ddbbda6602296c323d72d72024dd9caa (patch)
tree715a5a7f62c2004d9da7d8175fc9e2cab6774e7e
parent071bac8bd9c2f78aae1d185545cc141428d98a70 (diff)
Refactor refresh splash validation helpers
-rwxr-xr-xbin/photoalbum37
-rwxr-xr-xsrc/photoalbum.sh37
2 files changed, 40 insertions, 34 deletions
diff --git a/bin/photoalbum b/bin/photoalbum
index f43fe41..8645ef5 100755
--- a/bin/photoalbum
+++ b/bin/photoalbum
@@ -2345,6 +2345,22 @@ validate_dist_dir() {
fi
}
+validate_template_dir_access() {
+ if [[ ! -d "$TEMPLATE_DIR" || ! -r "$TEMPLATE_DIR" \
+ || ! -x "$TEMPLATE_DIR" ]]; then
+ config_error "TEMPLATE_DIR $TEMPLATE_DIR must be a readable directory"
+ fi
+}
+
+validate_template_file() {
+ local -r template_name="$1"; shift
+
+ if [ ! -r "$TEMPLATE_DIR/$template_name.tmpl" ]; then
+ config_error \
+ "template file $TEMPLATE_DIR/$template_name.tmpl must be readable"
+ fi
+}
+
validate_template_dir() {
local template_name
local -a required_templates=(
@@ -2358,20 +2374,14 @@ validate_template_dir() {
view
)
- if [[ ! -d "$TEMPLATE_DIR" || ! -r "$TEMPLATE_DIR" \
- || ! -x "$TEMPLATE_DIR" ]]; then
- config_error "TEMPLATE_DIR $TEMPLATE_DIR must be a readable directory"
- fi
+ validate_template_dir_access
if [ "${SPLASH_PAGE:-yes}" = yes ]; then
required_templates+=(splash)
fi
for template_name in "${required_templates[@]}"; do
- if [ ! -r "$TEMPLATE_DIR/$template_name.tmpl" ]; then
- config_error \
- "template file $TEMPLATE_DIR/$template_name.tmpl must be readable"
- fi
+ validate_template_file "$template_name"
done
}
@@ -2395,15 +2405,8 @@ validate_refresh_splash_config() {
validate_dist_dir
- if [[ ! -d "$TEMPLATE_DIR" || ! -r "$TEMPLATE_DIR" \
- || ! -x "$TEMPLATE_DIR" ]]; then
- config_error "TEMPLATE_DIR $TEMPLATE_DIR must be a readable directory"
- fi
-
- if [ ! -r "$TEMPLATE_DIR/splash.tmpl" ]; then
- config_error \
- "template file $TEMPLATE_DIR/splash.tmpl must be readable"
- fi
+ validate_template_dir_access
+ validate_template_file splash
if [ ! -d "$DIST_DIR/photos" ]; then
config_error "DIST_DIR photos directory $DIST_DIR/photos must exist"
diff --git a/src/photoalbum.sh b/src/photoalbum.sh
index a54616f..ae8b01d 100755
--- a/src/photoalbum.sh
+++ b/src/photoalbum.sh
@@ -2345,6 +2345,22 @@ validate_dist_dir() {
fi
}
+validate_template_dir_access() {
+ if [[ ! -d "$TEMPLATE_DIR" || ! -r "$TEMPLATE_DIR" \
+ || ! -x "$TEMPLATE_DIR" ]]; then
+ config_error "TEMPLATE_DIR $TEMPLATE_DIR must be a readable directory"
+ fi
+}
+
+validate_template_file() {
+ local -r template_name="$1"; shift
+
+ if [ ! -r "$TEMPLATE_DIR/$template_name.tmpl" ]; then
+ config_error \
+ "template file $TEMPLATE_DIR/$template_name.tmpl must be readable"
+ fi
+}
+
validate_template_dir() {
local template_name
local -a required_templates=(
@@ -2358,20 +2374,14 @@ validate_template_dir() {
view
)
- if [[ ! -d "$TEMPLATE_DIR" || ! -r "$TEMPLATE_DIR" \
- || ! -x "$TEMPLATE_DIR" ]]; then
- config_error "TEMPLATE_DIR $TEMPLATE_DIR must be a readable directory"
- fi
+ validate_template_dir_access
if [ "${SPLASH_PAGE:-yes}" = yes ]; then
required_templates+=(splash)
fi
for template_name in "${required_templates[@]}"; do
- if [ ! -r "$TEMPLATE_DIR/$template_name.tmpl" ]; then
- config_error \
- "template file $TEMPLATE_DIR/$template_name.tmpl must be readable"
- fi
+ validate_template_file "$template_name"
done
}
@@ -2395,15 +2405,8 @@ validate_refresh_splash_config() {
validate_dist_dir
- if [[ ! -d "$TEMPLATE_DIR" || ! -r "$TEMPLATE_DIR" \
- || ! -x "$TEMPLATE_DIR" ]]; then
- config_error "TEMPLATE_DIR $TEMPLATE_DIR must be a readable directory"
- fi
-
- if [ ! -r "$TEMPLATE_DIR/splash.tmpl" ]; then
- config_error \
- "template file $TEMPLATE_DIR/splash.tmpl must be readable"
- fi
+ validate_template_dir_access
+ validate_template_file splash
if [ ! -d "$DIST_DIR/photos" ]; then
config_error "DIST_DIR photos directory $DIST_DIR/photos must exist"