summaryrefslogtreecommitdiff
path: root/lib/feed2imap/imap.rb
diff options
context:
space:
mode:
authorlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2007-05-15 14:04:04 +0000
committerlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2007-05-15 14:04:04 +0000
commite6ab291ca9821a1f7e012481d4fdfb35fd7e996e (patch)
treef13d9e70c49eca6cb11d2c7a1a30685975bc0acf /lib/feed2imap/imap.rb
parent68bb1626532e4783160fbffffdd80132db978ba0 (diff)
downloadfeed2imap-e6ab291ca9821a1f7e012481d4fdfb35fd7e996e.tar.gz
feed2imap-e6ab291ca9821a1f7e012481d4fdfb35fd7e996e.tar.bz2
feed2imap-e6ab291ca9821a1f7e012481d4fdfb35fd7e996e.zip
Folder creation moved to upload
git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@122 f70e237a-67f3-0310-a06c-d2b8a7116972
Diffstat (limited to 'lib/feed2imap/imap.rb')
-rw-r--r--lib/feed2imap/imap.rb21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/feed2imap/imap.rb b/lib/feed2imap/imap.rb
index 933a561..3501530 100644
--- a/lib/feed2imap/imap.rb
+++ b/lib/feed2imap/imap.rb
@@ -50,6 +50,7 @@ class ImapAccount
def initialize(uri)
@uri = uri
+ @existing_folders = []
self
end
@@ -83,26 +84,26 @@ class ImapAccount
end
end
- # Returns true if the folder exist
- def folder_exist?(folder)
- return !@connection.list('', folder).nil?
- end
-
- # Creates the given folder
- def create_folder(folder)
- @connection.create(folder)
- @connection.subscribe(folder)
- self
+ # tests if the folder exists and create it if not
+ def create_folder_if_not_exists(folder)
+ return if @existing_folders.include?(folder)
+ if !@connection.list('', folder).nil?
+ @connection.create(folder)
+ @connection.subscribe(folder)
+ end
+ @existing_folders << folder
end
# Put the mail in the given folder
# You should check whether the folder exist first.
def putmail(folder, mail, date = Time::now)
+ create_folder_if_not_exists(folder)
@connection.append(folder, mail.gsub(/\n/, "\r\n"), nil, date)
end
# update a mail
def updatemail(folder, mail, idx, date = Time::now)
+ create_folder_if_not_exists(folder)
@connection.select(folder)
searchres = @connection.search(['HEADER', 'X-CacheIndex', "-#{idx}-"])
flags = nil