larch 1.1.0.dev.20091123 → 1.1.0.dev.20091126
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +3 -0
- data/lib/larch/imap.rb +22 -1
- data/lib/larch/version.rb +1 -1
- data/lib/larch.rb +8 -6
- metadata +2 -2
data/HISTORY
CHANGED
@@ -24,6 +24,9 @@ Version 1.1.0 (git)
|
|
24
24
|
* Fixed incorrect case-sensitive treatment of the 'INBOX' folder name.
|
25
25
|
* Fixed a bug in which Larch would try to copy flags that weren't supported on
|
26
26
|
the destination server.
|
27
|
+
* Fixed an issue when trying to copy a folder with leading or trailing
|
28
|
+
whitespace in the name to Gmail, since Gmail doesn't allow whitespace around
|
29
|
+
folder names.
|
27
30
|
|
28
31
|
Version 1.0.2 (2009-08-05)
|
29
32
|
* Fixed a bug that caused Larch to try to set the read-only \Recent flag on
|
data/lib/larch/imap.rb
CHANGED
@@ -6,7 +6,7 @@ module Larch
|
|
6
6
|
# required reading if you're doing anything with IMAP in Ruby:
|
7
7
|
# http://sup.rubyforge.org
|
8
8
|
class IMAP
|
9
|
-
attr_reader :conn, :db_account, :mailboxes, :options
|
9
|
+
attr_reader :conn, :db_account, :mailboxes, :options, :quirks
|
10
10
|
|
11
11
|
# URI format validation regex.
|
12
12
|
REGEX_URI = URI.regexp(['imap', 'imaps'])
|
@@ -57,6 +57,9 @@ class IMAP
|
|
57
57
|
@conn = nil
|
58
58
|
@mailboxes = {}
|
59
59
|
@mutex = Mutex.new
|
60
|
+
@quirks = {
|
61
|
+
:gmail => false
|
62
|
+
}
|
60
63
|
|
61
64
|
@db_account = Database::Account.find_or_create(
|
62
65
|
:hostname => host,
|
@@ -125,6 +128,9 @@ class IMAP
|
|
125
128
|
name = name.gsub(delim, self.delim)
|
126
129
|
name = 'INBOX' if name.downcase == 'inbox'
|
127
130
|
|
131
|
+
# Gmail doesn't allow folders with leading or trailing whitespace.
|
132
|
+
name.strip! if @quirks[:gmail]
|
133
|
+
|
128
134
|
begin
|
129
135
|
@mailboxes.fetch(name) do
|
130
136
|
update_mailboxes
|
@@ -231,6 +237,19 @@ class IMAP
|
|
231
237
|
|
232
238
|
private
|
233
239
|
|
240
|
+
# Tries to identify server implementations with certain quirks that we'll need
|
241
|
+
# to work around.
|
242
|
+
def check_quirks
|
243
|
+
return unless @conn &&
|
244
|
+
@conn.greeting.kind_of?(Net::IMAP::UntaggedResponse) &&
|
245
|
+
@conn.greeting.data.kind_of?(Net::IMAP::ResponseText)
|
246
|
+
|
247
|
+
if @conn.greeting.data.text =~ /^Gimap ready/
|
248
|
+
@quirks[:gmail] = true
|
249
|
+
debug "looks like Gmail"
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
234
253
|
# Resets the connection and mailbox state.
|
235
254
|
def reset
|
236
255
|
@mutex.synchronize do
|
@@ -282,6 +301,8 @@ class IMAP
|
|
282
301
|
|
283
302
|
info "connected on port #{port}" << (ssl? ? ' using SSL' : '')
|
284
303
|
|
304
|
+
check_quirks
|
305
|
+
|
285
306
|
auth_methods = ['PLAIN']
|
286
307
|
tried = []
|
287
308
|
capability = @conn.capability
|
data/lib/larch/version.rb
CHANGED
data/lib/larch.rb
CHANGED
@@ -115,16 +115,18 @@ module Larch
|
|
115
115
|
# Opens a connection to the Larch message database, creating it if
|
116
116
|
# necessary.
|
117
117
|
def open_db(database)
|
118
|
-
|
119
|
-
|
118
|
+
unless database == ':memory:'
|
119
|
+
filename = File.expand_path(database)
|
120
|
+
directory = File.dirname(filename)
|
120
121
|
|
121
|
-
|
122
|
-
|
123
|
-
|
122
|
+
unless File.exist?(directory)
|
123
|
+
FileUtils.mkdir_p(directory)
|
124
|
+
File.chmod(0700, directory)
|
125
|
+
end
|
124
126
|
end
|
125
127
|
|
126
128
|
begin
|
127
|
-
db = Sequel.
|
129
|
+
db = Sequel.sqlite(:database => filename)
|
128
130
|
db.test_connection
|
129
131
|
rescue => e
|
130
132
|
@log.fatal "unable to open message database: #{e}"
|
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.
|
4
|
+
version: 1.1.0.dev.20091126
|
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: 2009-11-
|
12
|
+
date: 2009-11-26 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|