@lock_update_thread = nil
end
+ def possibly_pluralize number_of, kind
+ "#{number_of} #{kind}" +
+ if number_of == 1 then "" else "s" end
+ end
+
def fancy_lock_error_message_for e
- secs = Time.now - e.mtime
- mins = secs.to_i / 60
+ secs = (Time.now - e.mtime).to_i
+ mins = secs / 60
time =
if mins == 0
- "#{secs.to_i} seconds"
+ possibly_pluralize secs , "second"
else
- "#{mins} minutes"
+ possibly_pluralize mins, "minute"
end
<<EOS
field_infos.add_field :date, :index => :untokenized
field_infos.add_field :body
field_infos.add_field :label
+ field_infos.add_field :attachments
field_infos.add_field :subject
field_infos.add_field :from
field_infos.add_field :to
:body => (entry[:body] || m.indexable_content),
:snippet => snippet, # always override
:label => labels.uniq.join(" "),
+ :attachments => (entry[:attachments] || m.attachments.uniq.join(" ")),
:from => (entry[:from] || (m.from ? m.from.indexable_content : "")),
:to => (entry[:to] || (m.to + m.cc + m.bcc).map { |x| x.indexable_content }.join(" ")),
:subject => (entry[:subject] || wrap_subj(Message.normalize_subj(m.subj))),
extraopts[:load_deleted] = true if subs =~ /\blabel:deleted\b/
## gmail style "is" operator
- subs = subs.gsub(/\b(is):(\S+)\b/) do
+ subs = subs.gsub(/\b(is|has):(\S+)\b/) do
field, label = $1, $2
case label
when "read"
end
end
+ ## gmail style attachments "filename" and "filetype" searches
+ subs = subs.gsub(/\b(filename|filetype):(\((.+?)\)\B|(\S+)\b)/) do
+ field, name = $1, ($3 || $4)
+ case field
+ when "filename"
+ Redwood::log "filename - translated #{field}:#{name} to attachments:(#{name.downcase})"
+ "attachments:(#{name.downcase})"
+ when "filetype"
+ Redwood::log "filetype - translated #{field}:#{name} to attachments:(*.#{name.downcase})"
+ "attachments:(*.#{name.downcase})"
+ end
+ end
+
if $have_chronic
chronic_failure = false
subs = subs.gsub(/\b(before|on|in|during|after):(\((.+?)\)\B|(\S+)\b)/) do