beautysh tools/db/update-file-state
This commit is contained in:
parent
a6abdc45ea
commit
eb0354cf87
@ -102,17 +102,17 @@ function main() {
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# file dont exist
|
# file dont exist
|
||||||
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck=$DATE WHERE ID=$ID;"
|
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck=$DATE WHERE ID=$ID;"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
#add new files ....
|
#add new files ....
|
||||||
cat "$list_tmp/new" | while read line; do
|
cat "$list_tmp/new" | while read line; do
|
||||||
file_add "$line"
|
file_add "$line"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
rm -r "$list_tmp/"
|
rm -r "$list_tmp/"
|
||||||
@ -147,23 +147,23 @@ function file_size() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function file_add() {
|
function file_add() {
|
||||||
echo 2DO
|
echo 2DO
|
||||||
local relrevpath="$(echo $1 | 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 relrevpath="$(echo $1 | 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)"
|
||||||
local FILE="$moviedir/$(echo $relrevpath | rev)"
|
local FILE="$moviedir/$(echo $relrevpath | rev)"
|
||||||
[ -f "$FILE" ] || return 1 #errer file not exist
|
[ -f "$FILE" ] || return 1 #errer file not exist
|
||||||
local MD5_new=$(md5sum "$FILE" | cut -c -32)
|
local MD5_new=$(md5sum "$FILE" | cut -c -32)
|
||||||
local SIZE_new="$(file_size "$FILE")"
|
local SIZE_new="$(file_size "$FILE")"
|
||||||
|
|
||||||
#db path exist && md5 same -> update this entry
|
#db path exist && md5 same -> update this entry
|
||||||
#db path exist && ttsync=exist/backup && md5 !same -> ttsync=del + new db entry
|
#db path exist && ttsync=exist/backup && md5 !same -> ttsync=del + new db entry
|
||||||
#or new db entry
|
#or new db entry
|
||||||
|
|
||||||
#db entry is{
|
#db entry is{
|
||||||
# chek if size ->md5 exist -> update path&name (MV)
|
# chek if size ->md5 exist -> update path&name (MV)
|
||||||
# else complete new entry
|
# else complete new entry
|
||||||
#}
|
#}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user