Skip to content

Commit

Permalink
Merge pull request #3197 from thomasjacquin/If-"type"-changes-to-RAW1…
Browse files Browse the repository at this point in the history
…6-ensure-"filename"-is-.png

If "type" changes to raw16 ensure "filename" is .png
  • Loading branch information
EricClaeys authored Dec 19, 2023
2 parents f69a3c3 + 384f3cb commit 209a2ac
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions config_repo/options.json.repo
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@
"options" : [
"type_values"
],
"checkchanges" : true,
"action" : "reload",
"advanced" : true
},
Expand Down
33 changes: 31 additions & 2 deletions scripts/makeChanges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ if [[ -f ${SETTINGS_FILE} ]]; then
check_website # invoke to set variables
fi

# Make sure RAW16 files have a .png extension.
function check_filename_type()
{
local EXTENSION="${1##*.}" # filename is passed in - get just the extension
local TYPE="$2"

if [[ ${TYPE} -eq 2 ]]; then # 2 is RAW16 in allsky_common.h - it must match
if [[ ${EXTENSION,,} != "png" ]]; then
echo -en "${wERROR}${ERROR_PREFIX}"
echo -n "ERROR: RAW16 images only work with .png files"
echo -n "; either change the Image Type or the Filename."
echo -e "${wNC}"
return 1
fi
fi
return 0
}

CAMERA_NUMBER=""
NUM_CHANGED=0

Expand Down Expand Up @@ -346,11 +364,20 @@ do
NEEDS_RESTART="true"
;;

"filename")
check_website && WEBSITE_CONFIG+=("config.imageName" "${LABEL}" "${NEW_VALUE}")
"type")
check_filename_type "$( settings '.filename' )" "${NEW_VALUE}" || OK="false"
NEEDS_RESTART="true"
;;

"filename")
if check_filename_type "${NEW_VALUE}" "$( settings '.type' )" ; then
check_website && WEBSITE_CONFIG+=("config.imageName" "${LABEL}" "${NEW_VALUE}")
NEEDS_RESTART="true"
else
OK="false"
fi
;;

"extratext")
# It's possible the user will create/populate the file while Allsky is running,
# so it's not an error if the file doesn't exist or is empty.
Expand Down Expand Up @@ -493,6 +520,8 @@ do
shift 4
done

[[ ${OK} == "false" ]] && exit 1

[[ ${NUM_CHANGED} -le 0 ]] && exit 0 # Nothing changed

USE_REMOTE_WEBSITE="$( settings ".useremotewebsite" )"
Expand Down

0 comments on commit 209a2ac

Please sign in to comment.