vmail 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,6 +12,11 @@ task :web do
12
12
  end
13
13
  end
14
14
 
15
+ desc "git push and rake release bumped version"
16
+ task :bumped do
17
+ `git commit -a -m'bump' && git push && rake release`
18
+ end
19
+
15
20
  desc "Run tests"
16
21
  task :test do
17
22
  $:.unshift File.expand_path("test")
@@ -41,26 +41,33 @@ module Vmail
41
41
  @imap.disconnect
42
42
  end
43
43
 
44
- def select_mailbox(mailbox)
44
+ def select_mailbox(mailbox, force=false)
45
45
  if MailboxAliases[mailbox]
46
46
  mailbox = MailboxAliases[mailbox]
47
47
  end
48
- if mailbox == @mailbox
48
+ if mailbox == @mailbox && !force
49
49
  return
50
50
  end
51
51
  log "selecting mailbox #{mailbox.inspect}"
52
52
  reconnect_if_necessary do
53
53
  log @imap.select(mailbox)
54
54
  end
55
- @status = @imap.status(mailbox, ["MESSAGES", "RECENT", "UNSEEN"])
56
- log "STATUS: #{@status.inspect}"
55
+ @mailbox = mailbox
56
+ get_mailbox_status
57
+ get_highest_message_id
58
+ return "OK"
59
+ end
60
+
61
+ def get_highest_message_id
57
62
  # get highest message ID
58
63
  res = @imap.fetch([1,"*"], ["ENVELOPE"])
59
64
  @num_messages = res[-1].seqno
60
65
  log "HIGHEST ID: #@num_messages"
61
- @mailbox = mailbox
62
- @bad_ids = []
63
- return "OK"
66
+ end
67
+
68
+ def get_mailbox_status
69
+ @status = @imap.status(@mailbox, ["MESSAGES", "RECENT", "UNSEEN"])
70
+ log "mailbox status: #{@status.inspect}"
64
71
  end
65
72
 
66
73
  def revive_connection
@@ -107,7 +114,6 @@ module Vmail
107
114
  id_set = id_set.split(',')
108
115
  end
109
116
  max_id = id_set.to_a[-1]
110
- log "fetch envelopes for #{id_set.inspect}"
111
117
  if id_set.to_a.empty?
112
118
  log "empty set"
113
119
  return ""
@@ -220,10 +226,10 @@ module Vmail
220
226
  @all_search = false
221
227
  end
222
228
  log "@all_search #{@all_search}"
223
- @query = query.join(' ')
224
- log "search query: #@query"
229
+ @query = query
230
+ log "search query: #@query.inspect"
225
231
  @ids = reconnect_if_necessary do
226
- @imap.search(@query)
232
+ @imap.search(@query.join(' '))
227
233
  end
228
234
  # save ids in @ids, because filtered search relies on it
229
235
  fetch_ids = if @all_search
@@ -239,9 +245,15 @@ module Vmail
239
245
 
240
246
  def update
241
247
  prime_connection
248
+ old_num_messages = @num_messages
249
+ # we need to re-select the mailbox to get the new highest id
250
+ select_mailbox(@mailbox, true)
251
+ update_query = @query
252
+ # set a new range filter
253
+ update_query[0] = "#{old_num_messages}:#{@num_messages}"
242
254
  ids = reconnect_if_necessary {
243
- log "search #@query"
244
- @imap.search(@query)
255
+ log "search #update_query"
256
+ @imap.search(update_query.join(' '))
245
257
  }
246
258
  # TODO change this. will throw error now
247
259
  new_ids = ids.select {|x| x > @ids.max}
@@ -1,3 +1,3 @@
1
1
  module Vmail
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi