WIP - on android 1
This commit is contained in:
parent
bad7a85cb9
commit
32df13b2dd
@ -60,7 +60,7 @@ function main() {
|
|||||||
|
|
||||||
#clean DB from old stuff
|
#clean DB from old stuff
|
||||||
{
|
{
|
||||||
db_query "DELETE From File WHERE Size=0;"
|
db_query "DELETE From File WHERE Size=0 OR MD5="" OR MD5 IS NULL;"
|
||||||
}
|
}
|
||||||
|
|
||||||
#erselle zwei dateilisten
|
#erselle zwei dateilisten
|
||||||
@ -79,48 +79,43 @@ function main() {
|
|||||||
FILE=$(db_query "SELECT CONCAT('$moviedir/', Folder, '/', Name) FROM File WHERE ID=$ID;")
|
FILE=$(db_query "SELECT CONCAT('$moviedir/', Folder, '/', Name) FROM File WHERE ID=$ID;")
|
||||||
if [ -f "$FILE"]; then
|
if [ -f "$FILE"]; then
|
||||||
SIZE=$(db_query "SELECT Size FROM File WHERE ID=$ID;")
|
SIZE=$(db_query "SELECT Size FROM File WHERE ID=$ID;")
|
||||||
[ "$SIZE" != "$(file_size "$FILE")"] && {
|
SIZE_new="$(file_size "$FILE")"
|
||||||
|
[ "$SIZE" != "$SIZE_new" ] && {
|
||||||
echo "FILE CHANGE: $FILE"
|
echo "FILE CHANGE: $FILE"
|
||||||
|
if [ "0" == "$SIZE_new" ]; then
|
||||||
|
#file exist but empty
|
||||||
|
#rm "$FILE" <- secure? 2check
|
||||||
|
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck=$DATE WHERE ID=$ID;"
|
||||||
|
else
|
||||||
#recalc md5 ... + check
|
#recalc md5 ... + check
|
||||||
#update DB
|
#update DB
|
||||||
|
MD5_new=$(md5sum "$FILE" | cut -c -32)
|
||||||
|
MD5=$(db_query "SELECT MD5 FROM File WHERE ID=$ID;")
|
||||||
|
|
||||||
|
if [ "$MD5" == "$MD5_new" ]; then
|
||||||
|
db_query "UPDATE File SET Size=$SIZE_new,TTCheck=$DATE WHERE ID=$ID;"
|
||||||
|
else
|
||||||
|
#new file/file changed!
|
||||||
|
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck=$DATE WHERE ID=$ID;"
|
||||||
|
file_add "$(db_query "SELECT CONCAT(Folder, '/', Name) FROM File WHERE ID=$ID;")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
# file dont exist
|
||||||
|
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck=$DATE WHERE ID=$ID;"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
MD5=$(db_query "SELECT MD5 FROM File WHERE ID=$ID;")
|
|
||||||
done
|
done
|
||||||
|
|
||||||
## dateiliste erstellen die mit DB abgeglichen wird
|
#add new files ....
|
||||||
|
cat "$list_tmp/new" | while read line; do
|
||||||
|
file_add "$line"
|
||||||
|
done
|
||||||
|
|
||||||
## alle die keien DB.PATH eintrag haben -> file_add
|
|
||||||
|
|
||||||
## Für alle existierenden Dateien:
|
rm -r "$list_tmp/"
|
||||||
## * Path=DB.PATH && TTSync == TTSYNC_DEL
|
|
||||||
## -> DB.Size != 0 && Size == DB.Size -> TTSYNC_DEL -> TTSYNC_EXIST // >>file_undel<< konsider other state ?!?
|
|
||||||
## -> DB.Size != 0 || Size != DB.Size -> compare if md5 is same
|
|
||||||
## -> Ja -> TTSYNC_DEL -> TTSYNC_EXIST // >>file_undel<<
|
|
||||||
## -> NA -> delete DB Entry
|
|
||||||
## * Path=DB.PATH && TTSync == TTSYNC_EXIST / TTSYNC_BACKUP
|
|
||||||
## -> DB.Size = 0 -> file_add_size
|
|
||||||
## -> Size != DB.Size -> compare if md5 is same
|
|
||||||
## -> Ja -> update file size (file_add_size)
|
|
||||||
## -> NA
|
|
||||||
## -> makr DB.FID = TTSYNC_DEL
|
|
||||||
## -> file_add // this is a new file
|
|
||||||
## * Path=DB.PATH && TTSync == TTSYNC_REMOTE
|
|
||||||
## -> DB.Size = 0 -> compare if md5 is same
|
|
||||||
## -> Ja
|
|
||||||
## -> update file size (file_add_size)
|
|
||||||
## -> TTSYNC_REMOTE to TTSYNC_BACKUP
|
|
||||||
## -> NA
|
|
||||||
## -> Size = DB.Size TTSYNC_REMOTE to TTSYNC_BACKUP
|
|
||||||
## -> Size != DB.Size // Error Remote CP incorect!!!
|
|
||||||
|
|
||||||
## alle nicht gecheckten path einträge in DB (fiels die nicht existieren)
|
|
||||||
## A: HDD kaput
|
|
||||||
## B: Absichtlich gelöscht
|
|
||||||
## hdd_check // ob eine HDD defekt ist bzw das mounten irgendwo fehlgeschlagen ist
|
|
||||||
## -> ja -> error mesage!
|
|
||||||
## -> na -> set DB.FID TTSYNC_DEL
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,15 +136,6 @@ function main() {
|
|||||||
moviedir=""$(echo $moviedir | sed 's|/$||g')""
|
moviedir=""$(echo $moviedir | sed 's|/$||g')""
|
||||||
[ -z "$moviedir" ] && exit 255 #catch case moviedir="/"
|
[ -z "$moviedir" ] && exit 255 #catch case moviedir="/"
|
||||||
|
|
||||||
function md5_out_exist() {
|
|
||||||
db_query "SELECT CONCAT(MD5, ' ', ' ' ,'$moviedir/', Folder, '/', Name) FROM File WHERE TTSync=$TTSYNC_EXIST OR TTSync=$TTSYNC_BACKUP;" >> $md5list
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function md5_out_del() {
|
|
||||||
db_query "SELECT CONCAT(MD5, ' ', ' ' ,'$moviedir/', Folder, '/', Name) FROM File WHERE TTSync=$TTSYNC_DEL;" >> $md5list
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# file_size <path> -> (du -b)/1024 [Kb]
|
# file_size <path> -> (du -b)/1024 [Kb]
|
||||||
function file_size() {
|
function file_size() {
|
||||||
@ -160,6 +146,13 @@ function file_size() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function file_add() {
|
||||||
|
echo "dumy func file_add [rel. path]
|
||||||
|
#chek if path still esist chek usw...
|
||||||
|
#chek if size ->md5 exist -> not new MV !!!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# db_query <query> -> result
|
# db_query <query> -> result
|
||||||
function db_query() {
|
function db_query() {
|
||||||
local args="-sN" #no headers, no grid
|
local args="-sN" #no headers, no grid
|
||||||
|
Loading…
Reference in New Issue
Block a user