time measurement

delete obsolete files
This commit is contained in:
Vincent Riquer 2013-03-19 02:38:41 +01:00
parent 76a858a40b
commit 2c868c4131

66
atom
View File

@ -1779,7 +1779,9 @@ do
eval exec $((200+wnum))'<"$tempdir"/worker${wnum}out'
done
concurrencychange=$(date +%s)
starttime=$concurrencychange
taskcount=$count
failed=0
while :
do
if read -n 1 -t 0.01 userinput
@ -1826,7 +1828,69 @@ do
" $((taskcount - remaining)) of $taskcount ($failed failed)"
done
echo
endtime=$(date +%s)
(( elapsedseconds = endtime - starttime ))
(( days =
elapsedseconds
/
( 24*60*60 )
)) || true
(( hours =
( elapsedseconds - ( days*24*60*60 ) )
/
( 60*60 )
)) || true
(( minutes =
( elapsedseconds - ( ( days*24*60*60 ) + ( hours*60*60 ) ) )
/
60
)) || true
(( seconds =
elapsedseconds
-
( ( days*24*60*60 ) + ( hours*60*60 ) + ( minutes*60) )
)) || true
echo -e "\rRan $taskcount tasks, $failed of which failed, in $days" \
"days, $hours hours, $minutes minutes and $seconds seconds."
echo '
SELECT id,
filename
FROM destination_files
WHERE source_file_id is NULL;
SELECT "AtOM:NoMoreFiles";
' >&3
deleted=0
removed=0
read -u4 line
until [[ $line == AtOM:NoMoreFiles ]]
do
id=${line%|*}
filename=${line#*|}
if [ -n "$filename" ]
then
if rm -f "$filename"
then
Delete destination_files <<<"id = $id"
(( ++deleted ))
fi
else
Delete destination_files <<<"id = $id"
(( ++removed ))
fi
read -u4 line
done
echo "Suppressed $deleted files, $removed removed from database"
echo "Purging empty directories."
for path in "${destinationpath[@]}"
do
find "$path" -type d -empty -delete
done
closeDatabase