commit 660bc6adae282615807182664b5030881b67df48
parent 5af8d042adb2ea37b72779ddb2bf1c0cc63da991
Author: Scott Bonds <scott@ggr.com>
Date: Mon, 15 Sep 2014 15:12:35 -0700
add support for special characters in source URIs
e.g. maildir:/home/scott/Maildir/%5BGmail%5D.All%20Mail
dry it up a bit
exclude directories from maildir email list
remove test file
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
@@ -22,7 +22,7 @@ class Maildir < Source
# sync by default if not specified
@sync_back = true if @sync_back.nil?
- @dir = uri.path
+ @dir = URI.decode uri.path
@labels = Set.new(labels || [])
@mutex = Mutex.new
@ctimes = { 'cur' => Time.at(0), 'new' => Time.at(0) }
@@ -120,7 +120,10 @@ class Maildir < Source
@ctimes[d] = ctime
old_ids = benchmark(:maildir_read_index) { Index.instance.enum_for(:each_source_info, self.id, "#{d}/").to_a }
- new_ids = benchmark(:maildir_read_dir) { Dir.glob("#{subdir}/*").map { |x| File.join(d,File.basename(x)) }.sort }
+ new_ids = benchmark(:maildir_read_dir) {
+ Dir.open(subdir).select {
+ |f| !File.directory? f}.map {
+ |x| File.join(d,File.basename(x)) }.sort }
added += new_ids - old_ids
deleted += old_ids - new_ids
debug "#{old_ids.size} in index, #{new_ids.size} in filesystem"