tool db/import-md5-lsit: handle ' in string

This commit is contained in:
6543 2019-02-09 04:48:25 +01:00
parent d45cfb7f20
commit 267f9c1550

View File

@ -75,11 +75,11 @@ function md5_in_add() {
cat $md5list | while read line; do #for each line in md5 cat $md5list | while read line; do #for each line in md5
local md5=$(echo $line | cut -c -32) local md5=$(echo $line | cut -c -32)
local path=$(echo $line | cut -c 33- | sed 's/^\ //g') local path=$(echo $line | cut -c 33- | sed 's/^\ //g')
local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev | sed "s/'/''/g") #last statement set ' as '' so it wont have an evect in the sql statement
local name=$(echo $relrevpath | cut -d '/' -f 1 | rev) local name=$(echo $relrevpath | cut -d '/' -f 1 | rev)
local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev)
if [ "$(db_query "SELECT COUNT(ID) FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';")" == "0" ]; then #wenn KEIN gleicher Eintrag Vorhanden if [ "$(db_query "SELECT COUNT(ID) FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';")" == "0" ]; then #wenn KEIN gleicher Eintrag Vorhanden
db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_EXIST );" #-> handle in future: ";'()" db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_EXIST );"
else else
db_query "UPDATE File SET TTSync=$TTSYNC_EXIST WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" db_query "UPDATE File SET TTSync=$TTSYNC_EXIST WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';"
fi fi
@ -92,10 +92,10 @@ function md5_rm() {
cat $md5list | while read line; do #for each line in md5 cat $md5list | while read line; do #for each line in md5
local md5=$(echo $line | cut -c -32) local md5=$(echo $line | cut -c -32)
local path=$(echo $line | cut -c 33- | sed 's/^\ //g') local path=$(echo $line | cut -c 33- | sed 's/^\ //g')
local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev | sed "s/'/''/g") #last statement set ' as '' so it wont have an evect in the sql statement
local name=$(echo $relrevpath | cut -d '/' -f 1 | rev) local name=$(echo $relrevpath | cut -d '/' -f 1 | rev)
local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev)
db_query "DELETE FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" #-> handle in future: ";'()" db_query "DELETE FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';"
done done


exit 0 exit 0
@ -105,14 +105,14 @@ function md5_in_del() {
cat $md5list | while read line; do #for each line in md5 cat $md5list | while read line; do #for each line in md5
local md5=$(echo $line | cut -c -32) local md5=$(echo $line | cut -c -32)
local path=$(echo $line | cut -c 33- | sed 's/^\ //g') local path=$(echo $line | cut -c 33- | sed 's/^\ //g')
local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev | sed "s/'/''/g") #last statement set ' as '' so it wont have an evect in the sql statement
local name=$(echo $relrevpath | cut -d '/' -f 1 | rev) local name=$(echo $relrevpath | cut -d '/' -f 1 | rev)
local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev)


if [ "$(db_query "SELECT COUNT(ID) FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';")" -gt "0" ]; then #wenn gleicher Eintrag Vorhanden if [ "$(db_query "SELECT COUNT(ID) FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';")" -gt "0" ]; then #wenn gleicher Eintrag Vorhanden
db_query "UPDATE File SET TTSync=$TTSYNC_DEL WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" #-> handle in future: ";'()" db_query "UPDATE File SET TTSync=$TTSYNC_DEL WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';"
else #Ansonsten Erstelle Del eintrag else #Ansonsten Erstelle Del eintrag
db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_DEL );" #-> handle in future: ";'()" db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_DEL );"
fi fi
done done