Copy more reliably when path change is not set
This commit is contained in:
parent
bb484454a6
commit
055ba6dec0
@ -43,42 +43,37 @@ copyFiles_action() {
|
|||||||
rest=${rest#*::AtOM:SQL:Sep::}
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
destfileid=${rest%%::AtOM:SQL:Sep::*}
|
destfileid=${rest%%::AtOM:SQL:Sep::*}
|
||||||
rest=${rest#*::AtOM:SQL:Sep::}
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
echo 'SELECT IFNULL( (
|
|
||||||
SELECT destination_files.filename
|
|
||||||
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 mime_type_actions.action = 1
|
|
||||||
LIMIT 1
|
|
||||||
),"AtOM:NotFound");
|
|
||||||
'>&3
|
|
||||||
read -u4 filename
|
|
||||||
if [[ $filename != AtOM:NotFound ]]
|
|
||||||
then
|
|
||||||
destdir=${filename%/*}
|
|
||||||
if cp -al "$sourcepath/$sourcefilename" "$destdir" 2>/dev/null\
|
|
||||||
|| cp -a "$sourcepath/$sourcefilename" "$destdir"
|
|
||||||
then
|
|
||||||
Update destination_files \
|
|
||||||
filename "$destdir/${sourcefilename##*/}"\
|
|
||||||
rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}"\
|
|
||||||
last_change $lastchange \
|
|
||||||
<<-EOWhere
|
|
||||||
id = $destfileid
|
|
||||||
EOWhere
|
|
||||||
(( done++ ))
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
(( count++ ))
|
(( count++ ))
|
||||||
printf '\b\b\b\b%3i%%' $(( (count * 100) / ${#copyfiles[@]} ))
|
printf '\b\b\b\b%3i%%' $(( (count * 100) / ${#copyfiles[@]} ))
|
||||||
|
if [ -n "${renamepath["$destination"]}" ]
|
||||||
|
then
|
||||||
|
destdir="$(guessPath)" || continue
|
||||||
|
else
|
||||||
|
destdir="${destinationpath["$destination"]}/"
|
||||||
|
destdir+=$(sanitizeFile "${sourcefilename%%/*}" dir)
|
||||||
|
part=${sourcefilename#*/}
|
||||||
|
while [[ $part =~ / ]]
|
||||||
|
do
|
||||||
|
destdir+="/$(sanitizeFile "${part%%/*}" dir)"
|
||||||
|
part=${part#*/}
|
||||||
|
done
|
||||||
|
if ! [ -d "$destdir" ]
|
||||||
|
then
|
||||||
|
mkdir -p "$destdir"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if cp -al "$sourcepath/$sourcefilename" "$destdir" 2>/dev/null\
|
||||||
|
|| cp -a "$sourcepath/$sourcefilename" "$destdir"
|
||||||
|
then
|
||||||
|
Update destination_files \
|
||||||
|
filename "$destdir/${sourcefilename##*/}"\
|
||||||
|
rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}"\
|
||||||
|
last_change $lastchange \
|
||||||
|
<<-EOWhere
|
||||||
|
id = $destfileid
|
||||||
|
EOWhere
|
||||||
|
(( done++ ))
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
echo -e "\rCopied ${done:-0} of $count files.\033[K"
|
echo -e "\rCopied ${done:-0} of $count files.\033[K"
|
||||||
|
|||||||
28
lib/copy/guessPath
Normal file
28
lib/copy/guessPath
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
guessPath() {
|
||||||
|
echo 'SELECT IFNULL( (
|
||||||
|
SELECT destination_files.filename
|
||||||
|
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 mime_type_actions.action = 1
|
||||||
|
LIMIT 1
|
||||||
|
),"AtOM:NotFound");
|
||||||
|
'>&3
|
||||||
|
read -u4 filename
|
||||||
|
if [[ $filename != AtOM:NotFound ]]
|
||||||
|
then
|
||||||
|
echo "${filename%/*}"
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user