Increase reliability of the copy.

* Continue if a copy fails
* Assume the filenames are in UTF-8
pull/10/head
Raphaël Vinot 2013-10-29 15:48:21 +01:00
parent 0458928515
commit c01482a8b1
4 changed files with 19 additions and 18 deletions

View File

@ -12,7 +12,7 @@ if [ $# -eq 3 ]; then
# uid= only works on a vfat FS. What should we do if we get an ext* FS ?
# the main problem is that we need the rw rights on the dest key.
# It is not possible to ensure it on a non-vfat USB key.
mount -t vfat -o user,noexec,nosuid,nodev,rw,uid="${1}" "${2}" "${3}"
mount -t vfat -o user,noexec,nosuid,nodev,rw,uid="${1}",utf8=1 "${2}" "${3}"
exit 0
else
echo 'Invalid number of arguments.'

View File

@ -4,7 +4,7 @@ set -e
#set -x
if [ $# -eq 2 ]; then
mount -o noexec,nosuid,nodev "${1}" "${2}"
mount -o noexec,nosuid,nodev,utf8=1 "${1}" "${2}"
# renaming autorun.inf on the source key. As it it case insensitive, we have to do the following...
ls "${2}" | grep -i autorun.inf | xargs -I {} mv "${2}"/{} "${2}"/DANGEROUS_{}_DANGEROUS || true
mount -o remount,ro "${1}" "${2}"

View File

@ -1,7 +1,5 @@
#!/bin/bash
set -e
#set -x
source ./constraint.sh
source ./constraint_conv.sh
@ -14,9 +12,9 @@ LOGFILE="${LOGS}/processing.txt"
# Something went wrong.
error_handler(){
echo "FAILED." >> ${LOGFILE}
echo "Something went wrong during the duplication of the last file." >> ${LOGFILE}
echo "Please open a bug on https://www.github.com/Rafiot/KittenGroomer" >> ${LOGFILE}
echo -e "\tSomething went wrong during the duplication of the last file." >> ${LOGFILE}
echo -e "\tPlease open a bug on https://www.github.com/Rafiot/KittenGroomer" >> ${LOGFILE}
continue
}
trap error_handler ERR TERM INT
@ -143,6 +141,8 @@ main(){
echo "Please specify the destination directory."
exit
fi
set -e
set -x
if [ -z ${2} ]; then
CURRENT_SRC=${SRC}
@ -177,31 +177,32 @@ main(){
echo -n "Processing ${file} (${mime})... " >> ${LOGFILE}
case "${main_mime}" in
"text")
text ${file} ${dest}
text ${file} ${dest} || error_handler
;;
"audio")
audio ${file} ${dest}
audio ${file} ${dest} || error_handler
;;
"image")
image ${file} ${dest}
image ${file} ${dest} || error_handler
;;
"video")
video ${file} ${dest}
video ${file} ${dest} || error_handler
;;
"application")
application ${file} ${dest} ${details}
application ${file} ${dest} ${details} || error_handler
;;
"example")
example ${file} ${dest}
example ${file} ${dest} || error_handler
;;
"message")
message ${file} ${dest}
message ${file} ${dest} || error_handler
;;
"model")
model ${file} ${dest}
model ${file} ${dest} || error_handler
;;
"multipart")
multipart ${file} ${dest}
multipart ${file} ${dest} || error_handler
;;
*)
echo "This should never happen... :]"
@ -211,7 +212,7 @@ main(){
echo "done." >> ${LOGFILE}
done
IFS=$SAVEIFS
return 0
}
echo "Copy finished successfully." >> ${LOGFILE}

View File

@ -106,7 +106,7 @@ do
LOGFILE="${LOGS}/processing.txt"
echo "==== Starting processing of ${SRC} to ${target_dir}. ====" >> ${LOGFILE}
main ${target_dir}
main ${target_dir} || true
echo "==== Done with ${SRC} to ${target_dir}. ====" >> ${LOGFILE}
ls -lR "${target_dir}"