fix file copy: don't copy files if we can't guess the destination path

This commit is contained in:
Vincent Riquer 2013-11-20 13:02:38 +01:00
parent ee5714f97a
commit 3d715ef18e
2 changed files with 42 additions and 3 deletions

View File

@ -45,9 +45,19 @@ copyFiles_action() {
rest=${rest#*::AtOM:SQL:Sep::}
(( count++ ))
(( cron )) || printf '\b\b\b\b%3i%%' $(( (count * 100) / ${#copyfiles[@]} ))
if [ -n "${renamepath["$destination"]}" ]
if [ -n "${destinationrenamepath["$destination"]}" ]
then
destdir="$(guessPath)" || continue
destdir="$(guessPath)"
guessstatus=$?
case $guessstatus in
1)
continue
;;
2)
(( postponed++ ))
continue
;;
esac
else
destdir="${destinationpath["$destination"]}/"
if [[ $sourcefilename =~ / ]]
@ -88,7 +98,8 @@ copyFiles_action() {
if (( count ))
then
(( cron )) || echo -n $'\r'
echo -n "Copied ${done:-0} of $count files."
echo -n "Copied ${done:-0} of $count" \
"files${postponed+ ($postponed postponed)}."
(( cron )) || echo -en "\033[K"
echo
else

View File

@ -1,6 +1,31 @@
#!/bin/bash
guessPath() {
echo 'SELECT IFNULL( (
SELECT destination_files.last_change
FROM destination_files
INNER JOIN source_files
ON destination_files.source_file_id=source_files.id
INNER JOIN mime_type_actions
ON
mime_type_actions.id=source_files.mime_type
INNER JOIN destinations
ON destinations.id=destination_files.destination_id
WHERE destinations.id = '$destinationid'
AND source_files.filename LIKE
"'"${sourcedir//\"/\"\"}"'/%"
AND NOT source_files.filename LIKE
"'"${sourcedir//\"/\"\"}"'/%/%"
AND mime_type_actions.action = 1
ORDER BY destination_files.last_change DESC
LIMIT 1
),"0.0");
'>&3
read -u4 timestamp
if (( ${timestamp/./} == 0 ))
then
return 2
fi
echo 'SELECT IFNULL( (
SELECT destination_files.filename
FROM destination_files
@ -14,7 +39,10 @@ guessPath() {
WHERE destinations.id = '$destinationid'
AND source_files.filename LIKE
"'"${sourcedir//\"/\"\"}"'/%"
AND NOT source_files.filename LIKE
"'"${sourcedir//\"/\"\"}"'/%/%"
AND mime_type_actions.action = 1
ORDER BY destination_files.last_change DESC
LIMIT 1
),"AtOM:NotFound");
'>&3