rgrove-larch 1.0.0.13 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -1,7 +1,7 @@
1
1
  Larch History
2
2
  ================================================================================
3
3
 
4
- Version 1.0.1 (?)
4
+ Version 1.0.1 (2009-05-10)
5
5
  * Ruby 1.9.1 support.
6
6
  * Much more robust handling of unexpected server disconnects and dropped
7
7
  connections.
@@ -15,9 +15,7 @@ Version 1.0.1 (?)
15
15
  * Added a new "insane" logging level, which will output all IMAP commands and
16
16
  responses to STDERR.
17
17
  * Fixed excessive post-scan processing times for very large mailboxes.
18
- * Message headers are now fetched in blocks of up to 1024 at a time rather
19
- than all at once to prevent potential problems with certain servers when a
20
- mailbox contains a huge number of messages.
18
+ * Fixed potential scan problems with very large mailboxes on certain servers.
21
19
  * POSIX signals are no longer trapped on platforms that aren't likely to
22
20
  support them.
23
21
 
data/README.rdoc CHANGED
@@ -8,7 +8,7 @@ Larch is particularly well-suited for copying email to, from, or between Gmail
8
8
  accounts.
9
9
 
10
10
  *Author*:: Ryan Grove (mailto:ryan@wonko.com)
11
- *Version*:: ? (?)
11
+ *Version*:: 1.0.1 (2009-05-10)
12
12
  *Copyright*:: Copyright (c) 2009 Ryan Grove. All rights reserved.
13
13
  *License*:: GPL 2.0 (http://opensource.org/licenses/gpl-2.0.php)
14
14
  *Website*:: http://github.com/rgrove/larch
@@ -4,9 +4,6 @@ module Larch; class IMAP
4
4
  class Mailbox
5
5
  attr_reader :attr, :delim, :imap, :name, :state
6
6
 
7
- # Maximum number of messages to fetch at once.
8
- MAX_FETCH_COUNT = 1024
9
-
10
7
  # Regex to capture a Message-Id header.
11
8
  REGEX_MESSAGE_ID = /message-id\s*:\s*(\S+)/i
12
9
 
@@ -20,7 +17,7 @@ class Mailbox
20
17
  @name = name
21
18
  @delim = delim
22
19
  @subscribed = subscribed
23
- @attr = *attr
20
+ @attr = *attr.flatten # flatten is necessary for Ruby 1.9
24
21
 
25
22
  @ids = {}
26
23
  @last_id = 0
@@ -130,12 +127,10 @@ class Mailbox
130
127
  end
131
128
 
132
129
  last_id = @imap.safely { @imap.conn.responses['EXISTS'].last }
133
-
134
130
  @mutex.synchronize { @last_scan = Time.now }
135
131
  return if last_id == @last_id
136
132
 
137
133
  range = (@last_id + 1)..last_id
138
-
139
134
  @mutex.synchronize { @last_id = last_id }
140
135
 
141
136
  info "fetching message headers #{range}" <<
@@ -147,7 +142,7 @@ class Mailbox
147
142
  "(UID BODY.PEEK[HEADER.FIELDS (MESSAGE-ID)] RFC822.SIZE INTERNALDATE)"
148
143
  end
149
144
 
150
- imap_fetch(range, fields).each do |data|
145
+ imap_fetch(range.begin..-1, fields).each do |data|
151
146
  id = create_id(data)
152
147
 
153
148
  unless uid = data.attr['UID']
@@ -228,23 +223,13 @@ class Mailbox
228
223
  return true
229
224
  end
230
225
 
231
- # Fetches the specified _fields_ for the specified message sequence id(s) from
232
- # this mailbox.
233
- def imap_fetch(ids, fields)
234
- ids = ids.to_a
235
- data = []
236
- pos = 0
237
-
238
- while pos < ids.length
239
- @imap.safely do
240
- imap_examine
241
-
242
- data += @imap.conn.fetch(ids[pos, MAX_FETCH_COUNT], fields)
243
- pos += MAX_FETCH_COUNT
244
- end
226
+ # Fetches the specified _fields_ for the specified _set_ of message sequence
227
+ # ids (either a Range or an Array of ids).
228
+ def imap_fetch(set, fields)
229
+ @imap.safely do
230
+ imap_examine
231
+ @imap.conn.fetch(set, fields)
245
232
  end
246
-
247
- data
248
233
  end
249
234
 
250
235
  # Selects the mailbox if it is not already selected. If the mailbox does not
@@ -280,23 +265,13 @@ class Mailbox
280
265
  return true
281
266
  end
282
267
 
283
- # Fetches the specified _fields_ for the specified UID(s) from the IMAP
284
- # server.
285
- def imap_uid_fetch(uids, fields)
286
- uids = uids.to_a
287
- data = []
288
- pos = 0
289
-
290
- while pos < uids.length
291
- @imap.safely do
292
- imap_examine
293
-
294
- data += @imap.conn.uid_fetch(uids[pos, MAX_FETCH_COUNT], fields)
295
- pos += MAX_FETCH_COUNT
296
- end
268
+ # Fetches the specified _fields_ for the specified _set_ of UIDs (either a
269
+ # Range or an Array of UIDs).
270
+ def imap_uid_fetch(set, fields)
271
+ @imap.safely do
272
+ imap_examine
273
+ @imap.conn.uid_fetch(set, fields)
297
274
  end
298
-
299
- data
300
275
  end
301
276
 
302
277
  end
data/lib/larch/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Larch
2
2
  APP_NAME = 'Larch'
3
- APP_VERSION = '1.0.0.13'
3
+ APP_VERSION = '1.0.1'
4
4
  APP_AUTHOR = 'Ryan Grove'
5
5
  APP_EMAIL = 'ryan@wonko.com'
6
6
  APP_URL = 'http://github.com/rgrove/larch/'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgrove-larch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.13
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Grove