Skip to content

Commit

Permalink
No longer always download RFC822.Size as it is slow on some servers
Browse files Browse the repository at this point in the history
  • Loading branch information
mronge committed Mar 1, 2013
1 parent 95861d3 commit b52df2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Source/CTCoreFolder.h
Expand Up @@ -92,12 +92,12 @@
This method take fetch attributes which configure what is fetched. Fetch attributes can be combined
so you fetch all the message data at once, or select which pieces you want for your app. You can
also fetch just the default attributes which will be as fast as possible. Pass in
CTFetchAttrDefaultsOnly to attrs fetch the minimum possible, this includes the UID, RFC822.size, and
CTFetchAttrDefaultsOnly to attrs fetch the minimum possible, this includes the UID and
flags. The defaults are always fetched, even when you don't pass in this flag. Use
CTFetchAttrBodyStructure to also fetch the body structure of the message. This prevents a future
round trip done by [CTCoreMessage fetchBodyStructure], if it sees you already have the body
structure it won't re-fetch it. Use CTFetchAttrEnvelope if you'd like to fetch the subject, to,
from, cc, bcc, sender, date etc. You can also fetch both the envelope and body structure by passing
from, cc, bcc, sender, date, size, etc. You can also fetch both the envelope and body structure by passing
in CTFetchAttrEnvelope | CTFetchAttrBodyStructure
Expand Down
20 changes: 11 additions & 9 deletions Source/CTCoreFolder.m
Expand Up @@ -433,7 +433,7 @@ - (BOOL)sequenceNumberForUID:(NSUInteger)uid sequenceNumber:(NSUInteger *)sequen
return YES;
}

// We always fetch UID, RFC822.Size, and Flags
// We always fetch UID and Flags
- (NSArray *)messagesForSet:(struct mailimap_set *)set fetchAttributes:(CTFetchAttributes)attrs uidFetch:(BOOL)uidFetch {
BOOL success = [self connect];
if (!success) {
Expand Down Expand Up @@ -470,14 +470,16 @@ - (NSArray *)messagesForSet:(struct mailimap_set *)set fetchAttributes:(CTFetchA
return nil;
}

// Always fetch RFC822.Size
fetch_att = mailimap_fetch_att_new_rfc822_size();
r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
if (r != MAILIMAP_NO_ERROR) {
mailimap_fetch_att_free(fetch_att);
mailimap_fetch_type_free(fetch_type);
self.lastError = MailCoreCreateErrorFromIMAPCode(r);
return nil;
// We only fetch RFC822.Size if the envelope is being fetched
if (attrs & CTFetchAttrEnvelope) {
fetch_att = mailimap_fetch_att_new_rfc822_size();
r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
if (r != MAILIMAP_NO_ERROR) {
mailimap_fetch_att_free(fetch_att);
mailimap_fetch_type_free(fetch_type);
self.lastError = MailCoreCreateErrorFromIMAPCode(r);
return nil;
}
}

// We only fetch the body structure if requested
Expand Down

0 comments on commit b52df2d

Please sign in to comment.