Attempt to fix long messages list on synchronize
This commit is contained in:
parent
b3d16dcac8
commit
f2388c1fd4
3 changed files with 22 additions and 12 deletions
|
@ -375,11 +375,22 @@ class IMAPFolder
|
|||
@mailbox.imap.expunge
|
||||
end
|
||||
|
||||
def synchronize_cache
|
||||
def synchronize_cache(offset=0, limit = 10)
|
||||
to = limit+offset
|
||||
startSync = Time.now
|
||||
activate
|
||||
startUidFetch = Time.now
|
||||
server_messages = @mailbox.imap.uid_fetch(1..-1, ['UID', 'FLAGS'])
|
||||
|
||||
#Count all messages
|
||||
count = @mailbox.imap.fetch(1..-1, "UID")
|
||||
to = count.size if count.size < to
|
||||
|
||||
|
||||
range = (offset..to)
|
||||
logger.info range.inspect
|
||||
|
||||
server_messages = @mailbox.imap.fetch(range, "(UID FLAGS)")
|
||||
#server_messages = @mailbox.imap.uid_fetch(sequence_uids, ["UID", "FLAGS"])
|
||||
|
||||
startDbFetch = Time.now
|
||||
cached_messages = ImapMessage.find(:all, :conditions => ["username = ? and folder_name = ?", @username, @name])
|
||||
|
@ -427,7 +438,7 @@ class IMAPFolder
|
|||
fetch_uids(slice)
|
||||
end
|
||||
end
|
||||
@mcached = true
|
||||
#FIX: @mcached = true
|
||||
logger.debug("Synchonization done for folder #{@name} in #{Time.now - startSync} ms.")
|
||||
end
|
||||
|
||||
|
@ -449,14 +460,14 @@ class IMAPFolder
|
|||
}
|
||||
end
|
||||
|
||||
def messages(offset = 0, limit = 10, sort = 'date desc')
|
||||
def messages(offset = 1, limit = 10, sort = 'date desc')
|
||||
# Synchronize first retrieval time
|
||||
synchronize_cache unless @mcached
|
||||
synchronize_cache(offset, limit) #unless @mcached
|
||||
|
||||
if limit == -1
|
||||
@messages = ImapMessage.find(:all, :conditions => ["username = ? and folder_name = ?", @username, @name], :order => sort)
|
||||
else
|
||||
@messages = ImapMessage.find(:all, :conditions => ["username = ? and folder_name = ?", @username, @name], :order => sort, :limit => limit, :offset => offset )
|
||||
@messages = ImapMessage.find(:all, :conditions => ["username = ? and folder_name = ?", @username, @name], :order => sort )
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -140,7 +140,11 @@ module Mail2Screen
|
|||
end
|
||||
|
||||
def friendly_address_or_name(addr)
|
||||
addr.kind_of?(Net::IMAP::Address) ? ((addr.name.nil? or addr.name.to_s == "") ? "#{addr.mailbox}@#{addr.host}" : (mime_encoded?(addr.name.to_s) ? mime_decode(addr.name.to_s): addr.name.to_s)) : ((addr.name.nil? or addr.name.to_s == "") ? "#{addr.spec}" : (mime_encoded?(addr.name.to_s) ? mime_decode(addr.name.to_s): addr.name.to_s))
|
||||
if addr.kind_of?(Net::IMAP::Address)
|
||||
((addr.name.nil? or addr.name.to_s == "") ? "#{addr.mailbox}@#{addr.host}" : (mime_encoded?(addr.name.to_s) ? mime_decode(addr.name.to_s): addr.name.to_s))
|
||||
else
|
||||
((addr.nil? or addr.to_s == "") ? "#{addr.to_s}" : (mime_encoded?(addr.to_s) ? mime_decode(addr.to_s): addr.to_s))
|
||||
end
|
||||
end
|
||||
|
||||
def add_to_contact(addr, msg_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue