Add logging, better error handling.

pull/10/head
Raphaël Vinot 2013-06-09 19:37:41 +02:00
parent 44ecee3884
commit 8c157441c5
2 changed files with 21 additions and 2 deletions

View File

@ -9,6 +9,18 @@ source ./constraint_conv.sh
RECURSIVE_ARCHIVE_MAX=3 RECURSIVE_ARCHIVE_MAX=3
RECURSIVE_ARCHIVE_CURRENT=0 RECURSIVE_ARCHIVE_CURRENT=0
ARCHIVE_BOMB=0 ARCHIVE_BOMB=0
LOGFILE="${LOGS}/processing"
# Something went wrong.
error_handler(){
echo "FAILED." >> ${LOGFILE}
echo "Something went wrong during the duplication." >> ${LOGFILE}
echo "Please open a bug on https://www.github.com/Rafiot/KittenGroomer" >> ${LOGFILE}
exit
}
trap error_handler INT
copy(){ copy(){
src_file=${1} src_file=${1}
@ -143,6 +155,9 @@ main(){
if [ ${RECURSIVE_ARCHIVE_CURRENT} -gt ${RECURSIVE_ARCHIVE_MAX} ]; then if [ ${RECURSIVE_ARCHIVE_CURRENT} -gt ${RECURSIVE_ARCHIVE_MAX} ]; then
echo Archive bomb. echo Archive bomb.
ARCHIVE_BOMB=1 ARCHIVE_BOMB=1
echo "ARCHIVE BOMB." >> ${LOGFILE}
echo "The content of the archive contains recursively other archives." >> ${LOGFILE}
echo "This is a bad sign so the archive is not extracted to the destination key." >> ${LOGFILE}
return return
else else
RECURSIVE_ARCHIVE_CURRENT=`expr ${RECURSIVE_ARCHIVE_CURRENT} + 1` RECURSIVE_ARCHIVE_CURRENT=`expr ${RECURSIVE_ARCHIVE_CURRENT} + 1`
@ -160,6 +175,7 @@ main(){
echo ${mime} echo ${mime}
main_mime=`echo ${mime} | cut -f1 -d/` main_mime=`echo ${mime} | cut -f1 -d/`
details=`echo ${mime} | cut -f2 -d/` details=`echo ${mime} | cut -f2 -d/`
echo -n "Processing ${file} (${mime})... " >> ${LOGFILE}
case "${main_mime}" in case "${main_mime}" in
"text") "text")
text ${file} ${dest} text ${file} ${dest}
@ -193,6 +209,7 @@ main(){
echo $mime $main_mime $details echo $mime $main_mime $details
;; ;;
esac esac
echo "done." >> ${LOGFILE}
done done
IFS=$SAVEIFS IFS=$SAVEIFS
} }

View File

@ -81,7 +81,6 @@ fi
# Groom da kitteh! # Groom da kitteh!
COPYDIRTYPDF=0
PARTCOUNT=1 PARTCOUNT=1
for partition in ${DEV_PARTITIONS} for partition in ${DEV_PARTITIONS}
do do
@ -98,14 +97,17 @@ do
echo "${partition} mounted at ${SRC}" echo "${partition} mounted at ${SRC}"
# Print the filenames on the current partition in a logfile # Print the filenames on the current partition in a logfile
find "${SRC}" -fls "${LOGS}/${PARTCOUNT}" find "${SRC}" -fls "${LOGS}/Content_partition_${PARTCOUNT}"
# create a directory on ${DST} named PARTION_$PARTCOUNT # create a directory on ${DST} named PARTION_$PARTCOUNT
target_dir="${DST}/FROM_PARTITION_${PARTCOUNT}" target_dir="${DST}/FROM_PARTITION_${PARTCOUNT}"
echo "copying to: ${target_dir}" echo "copying to: ${target_dir}"
mkdir -p "${target_dir}" mkdir -p "${target_dir}"
LOGFILE="${LOGS}/processing"
echo "==== Starting processing of ${SRC} to ${target_dir}. ====" >> ${LOGFILE}
main ${target_dir} main ${target_dir}
echo "==== Done with ${SRC} to ${target_dir}. ====" >> ${LOGFILE}
ls -lR "${target_dir}" ls -lR "${target_dir}"
fi fi