larch 1.1.0.dev.20100208 → 1.1.0.dev.20100209

Sign up to get free protection for your applications and to get access to all the features.
@@ -82,6 +82,21 @@ class Mailbox
82
82
  end
83
83
  alias << append
84
84
 
85
+ # Deletes the message in this mailbox with the specified guid. Returns +true+
86
+ # on success, +false+ on failure.
87
+ def delete_message(guid)
88
+ if @imap.quirks[:gmail]
89
+ return false unless db_message = fetch_db_message(guid)
90
+
91
+ debug "moving message to Gmail trash: #{guid}"
92
+
93
+ @imap.safely { @imap.conn.uid_copy(db_message.uid, '[Gmail]/Trash') } &&
94
+ set_flags(guid, [:Deleted], true)
95
+ else
96
+ set_flags(guid, [:Deleted], true)
97
+ end
98
+ end
99
+
85
100
  # Iterates through messages in this mailbox, yielding a
86
101
  # Larch::Database::Message object for each to the provided block.
87
102
  def each_db_message # :yields: db_message
@@ -142,7 +157,7 @@ class Mailbox
142
157
 
143
158
  # Returns a Larch::Database::Message object representing the message with the
144
159
  # specified Larch _guid_, or +nil+ if the specified guide was not found in
145
- # this mailbox.
160
+ # this mailbox.
146
161
  def fetch_db_message(guid)
147
162
  scan
148
163
  @db_mailbox.messages_dataset.filter(:guid => guid).first
@@ -227,11 +242,13 @@ class Mailbox
227
242
  end
228
243
 
229
244
  @db_mailbox.update(:uidvalidity => status['UIDVALIDITY'])
230
- return unless flag_range || full_range.last - full_range.first > 0
231
245
 
232
- fetch_flags(flag_range) if flag_range && flag_range.last - flag_range.first > 0
246
+ need_flag_scan = flag_range && flag_range.max && flag_range.min && flag_range.max - flag_range.min > 0
247
+ need_full_scan = full_range && full_range.max && full_range.min && full_range.max - full_range.min > 0
248
+
249
+ fetch_flags(flag_range) if need_flag_scan
233
250
 
234
- if full_range && full_range.last - full_range.first > 0
251
+ if need_full_scan
235
252
  fetch_headers(full_range, {
236
253
  :progress_start => @db_mailbox.messages_dataset.count + 1,
237
254
  :progress_total => status['MESSAGES']
data/lib/larch/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Larch
2
2
  APP_NAME = 'Larch'
3
- APP_VERSION = '1.1.0.dev.20100208'
3
+ APP_VERSION = '1.1.0.dev.20100209'
4
4
  APP_AUTHOR = 'Ryan Grove'
5
5
  APP_EMAIL = 'ryan@wonko.com'
6
6
  APP_URL = 'http://github.com/rgrove/larch/'
data/lib/larch.rb CHANGED
@@ -205,9 +205,9 @@ module Larch
205
205
 
206
206
  if @config['delete'] && !from_db_message.flags.include?(:Deleted)
207
207
  @log.info "[<] deleting uid #{uid} (already exists at destination)"
208
- mailbox_from.set_flags(guid, [:Deleted], true)
209
- @deleted += 1
208
+ @deleted += 1 if mailbox_from.delete_message(guid)
210
209
  end
210
+
211
211
  rescue Larch::IMAP::Error => e
212
212
  @log.error e.message
213
213
  end
@@ -232,8 +232,7 @@ module Larch
232
232
 
233
233
  if @config['delete']
234
234
  @log.info "[<] deleting uid #{uid}"
235
- mailbox_from.set_flags(guid, [:Deleted], true)
236
- @deleted += 1
235
+ @deleted += 1 if mailbox_from.delete_message(guid)
237
236
  end
238
237
 
239
238
  rescue Larch::IMAP::Error => e
@@ -251,6 +250,10 @@ module Larch
251
250
  @log.error e.message
252
251
  end
253
252
  end
253
+
254
+ rescue Larch::IMAP::Error => e
255
+ @log.error e.message
256
+
254
257
  end
255
258
 
256
259
  def db_maintenance
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: larch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.dev.20100208
4
+ version: 1.1.0.dev.20100209
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Grove
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-08 00:00:00 -08:00
12
+ date: 2010-02-09 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency