Commit 9de1e703 authored by Roque's avatar Roque

bug fixing: check invalid dataset name before store it in local config file

- fix indentation
parent 5775db93
......@@ -62,6 +62,7 @@ function helpReadme {
}
function checkParameters {
re='^[_A-Za-z.0-9-]*$'
if [ ! -f $TEMPLATE_FILE ]; then
echo
echo -e "${ORANGE}[ERROR] File '$TEMPLATE_FILE' not found!${NC}" >&2; return 1
......@@ -91,6 +92,19 @@ function checkParameters {
fi
fi
EBULK_DATASET_FILE="$DATASET_DIR$EBULK_DATASET_FILE_NAME"
if ! [[ $REFERENCE =~ $re ]] ; then
if [ "$REFERENCE" = "." ] && [[ -z "$STORAGE" ]] ; then
echo
echo -e "${ORANGE}[ERROR] You are not in a dataset directory ${GREEN}'$REFERENCE'${ORANGE}.${NC}"
echo
else
echo
echo -e "${ORANGE}[ERROR] Error in argument: invalid dataset name ${GREEN}'$REFERENCE'${ORANGE}.${NC}"
echo -e "${ORANGE}[ERROR] Only alphanumerics, dots ( . ), underscores ( _ ) and hyphens ( - ) are allowed.${NC}"
echo
fi
helpReadme >&2; return 1
fi
if [[ $DATASET_DIR != $REFERENCE ]]; then
if [ "$REFERENCE" = "." ] ; then
REFERENCE=$(basename "$DATASET_DIR")
......@@ -124,7 +138,6 @@ function checkParameters {
if [ "$DATA_SET" == "." ] ; then
DATA_SET=$(basename $(pwd))
fi
re='^[_A-Za-z.0-9-]*$'
if ! [[ $DATA_SET =~ $re ]] ; then
if [ "$DATA_SET" = "." ] && [[ -z "$STORAGE" ]] ; then
echo
......@@ -750,6 +763,9 @@ case $OPERATION in
echo
fi
echo "### DATASET DOWNLOAD ###"
if [ "$ALWAYS_YES" = "true" ] ; then
echo "[always yes mode]"
fi
echo
if [ "$DISCARD_CHANGES" != "" ] ; then
DISCARD_CHANGES_FILE="$DATASET_DIR$DISCARD_CHANGES_FILE_NAME"
......@@ -759,8 +775,10 @@ case $OPERATION in
echo -e "** The dataset will be downloaded in the specified directory: $DATASET_DIR"
fi
echo
read -n 1 -s -r -p "Press any key to continue"
echo
if [ "$ALWAYS_YES" = "false" ] ; then
read -n 1 -s -r -p "Press any key to continue"
echo
fi
runProcess
;;
push)
......@@ -799,12 +817,17 @@ case $OPERATION in
esac
fi
echo "### DATASET INGESTION ###"
echo
echo -e "** The tool will look for dataset files in the specified $MESSAGE"
echo -e "** Please make sure to put your dataset files there for ingestion."
echo
read -n 1 -s -r -p "Press any key to continue"
echo
if [ "$ALWAYS_YES" = "true" ] ; then
echo "[always yes mode]"
else
echo
echo -e "** The tool will look for dataset files in the specified $MESSAGE"
echo -e "** Please make sure to put your dataset files there for ingestion."
echo
read -n 1 -s -r -p "Press any key to continue"
fi
echo
runProcess
;;
esac
......
......@@ -138,9 +138,9 @@ module Embulk
@logger.error("Your current dataset is outdated. Please, run a download to update it before ingest your changes.", print=TRUE)
puts
@logger.abortExecution(error=FALSE)
end
end
end
end
end
end
@logger.info("Supplier: #{task['supplier']}")
@logger.info("Dataset name: #{task['data_set']}")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment