Skip to content

Commit

Permalink
Stop mail fetching if it is requested
Browse files Browse the repository at this point in the history
Fixes #36
  • Loading branch information
prehor authored and robbavey committed Apr 25, 2019
1 parent 8d691dd commit f3bac92
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/logstash/inputs/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,20 @@ def check_mail(queue)
queue << parse_mail(mail)
end
@uid_last_value = item.attr["UID"]

# Stop mail fetching if it is requested
break if @stop_called.true?
end

@logger.info("Saving \"uid_last_value\": \"#{@uid_last_value}\"")

# Always save @uid_last_value so when tracking is switched from
# "NOT SEEN" to "UID" we will continue from first unprocessed message
File.write(@sincedb_path, @uid_last_value) unless @uid_last_value.nil?
imap.store(id_set, '+FLAGS', @delete ? :Deleted : :Seen)

# Stop mail fetching if it is requested
break if @stop_called.true?
end

# Enable an 'expunge' IMAP command after the items.each loop
Expand Down

0 comments on commit f3bac92

Please sign in to comment.