fix file copy: don't copy files if we can't guess the destination path
This commit is contained in:
parent
ee5714f97a
commit
3d715ef18e
@ -45,9 +45,19 @@ copyFiles_action() {
|
|||||||
rest=${rest#*::AtOM:SQL:Sep::}
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
(( count++ ))
|
(( count++ ))
|
||||||
(( cron )) || printf '\b\b\b\b%3i%%' $(( (count * 100) / ${#copyfiles[@]} ))
|
(( cron )) || printf '\b\b\b\b%3i%%' $(( (count * 100) / ${#copyfiles[@]} ))
|
||||||
if [ -n "${renamepath["$destination"]}" ]
|
if [ -n "${destinationrenamepath["$destination"]}" ]
|
||||||
then
|
then
|
||||||
destdir="$(guessPath)" || continue
|
destdir="$(guessPath)"
|
||||||
|
guessstatus=$?
|
||||||
|
case $guessstatus in
|
||||||
|
1)
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
(( postponed++ ))
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
destdir="${destinationpath["$destination"]}/"
|
destdir="${destinationpath["$destination"]}/"
|
||||||
if [[ $sourcefilename =~ / ]]
|
if [[ $sourcefilename =~ / ]]
|
||||||
@ -88,7 +98,8 @@ copyFiles_action() {
|
|||||||
if (( count ))
|
if (( count ))
|
||||||
then
|
then
|
||||||
(( cron )) || echo -n $'\r'
|
(( 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"
|
(( cron )) || echo -en "\033[K"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
|
|||||||
@ -1,6 +1,31 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
guessPath() {
|
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( (
|
echo 'SELECT IFNULL( (
|
||||||
SELECT destination_files.filename
|
SELECT destination_files.filename
|
||||||
FROM destination_files
|
FROM destination_files
|
||||||
@ -14,7 +39,10 @@ guessPath() {
|
|||||||
WHERE destinations.id = '$destinationid'
|
WHERE destinations.id = '$destinationid'
|
||||||
AND source_files.filename LIKE
|
AND source_files.filename LIKE
|
||||||
"'"${sourcedir//\"/\"\"}"'/%"
|
"'"${sourcedir//\"/\"\"}"'/%"
|
||||||
|
AND NOT source_files.filename LIKE
|
||||||
|
"'"${sourcedir//\"/\"\"}"'/%/%"
|
||||||
AND mime_type_actions.action = 1
|
AND mime_type_actions.action = 1
|
||||||
|
ORDER BY destination_files.last_change DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
),"AtOM:NotFound");
|
),"AtOM:NotFound");
|
||||||
'>&3
|
'>&3
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user