Fixed inotify mechanism.

This commit is contained in:
Louwrentius 2010-07-18 09:37:19 +00:00
parent 20e8cdce95
commit 1575fb28f6

33
ppss
View File

@ -1561,14 +1561,19 @@ upload_item () {
} }
lock_item () { lock_item () {
ITEM="$1" if [ "$INOTIFY" = "1" ] && [ "$DAEMON" = "1" ]
LOCK_FILE_NAME_MD5=`echo "$ITEM" | $MD5 | awk '{ print $1 }'` then
ITEM_LOCK_FILE="$ITEM_LOCK_DIR/$LOCK_FILE_NAME_MD5" return 0
log DEBUG "Locking item $ITEM_LOCK_FILE" else
exec_cmd "mkdir $ITEM_LOCK_FILE >> /dev/null 2>&1" ITEM="$1"
ERROR="$?" LOCK_FILE_NAME_MD5=`echo "$ITEM" | $MD5 | awk '{ print $1 }'`
return "$ERROR" ITEM_LOCK_FILE="$ITEM_LOCK_DIR/$LOCK_FILE_NAME_MD5"
log DEBUG "Locking item $ITEM_LOCK_FILE"
exec_cmd "mkdir $ITEM_LOCK_FILE >> /dev/null 2>&1"
ERROR="$?"
return "$ERROR"
fi
} }
get_input_lock () { get_input_lock () {
@ -2173,6 +2178,8 @@ run_command () {
INPUT="$REGISTER" INPUT="$REGISTER"
fi fi
log DEBUG "Now processing $INPUT"
if [ ! -d "$INPUT" ] && [ ! -z "$INPUT" ] if [ ! -d "$INPUT" ] && [ ! -z "$INPUT" ]
then then
commando "$INPUT" & commando "$INPUT" &
@ -2272,7 +2279,10 @@ inotify_listener () {
inotifywait "$SRC_DIR" -m -e close -q --format '%w%f' | \ inotifywait "$SRC_DIR" -m -e close -q --format '%w%f' | \
while read -r line while read -r line
do do
echo "$line" > "$FIFO" if [ ! -d "$line" ]
then
echo "$line" > "$FIFO"
fi
done done
} }
@ -2300,7 +2310,6 @@ is_item_unprocessed () {
return $STATUS return $STATUS
} }
is_item_file_and_unmodified () { is_item_file_and_unmodified () {
ITEM="$1" ITEM="$1"
@ -2434,7 +2443,7 @@ listen_for_job () {
fi fi
else else
log DEBUG "Daemon mode: a worker finished..." log DEBUG "Daemon mode: a worker finished..."
run_command run_command
fi fi
elif [ "$event" == "$KILL_KEY" ] elif [ "$event" == "$KILL_KEY" ]
@ -2442,7 +2451,7 @@ listen_for_job () {
infanticide infanticide
break break
else else
log DEBUG "Event is an item!" log DEBUG "Event $event is an item!"
stack_push "$event" stack_push "$event"
run_command run_command
fi fi