Closed Bug 548584 Opened 14 years ago Closed 14 years ago

IMAP Condstore server results in wrong folder size

Categories

(Thunderbird :: Folder and Message Lists, defect)

x86
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 3.1b2

People

(Reporter: nico, Assigned: Bienvenu)

References

()

Details

(Whiteboard: [gs])

Attachments

(1 file, 2 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2) Gecko/20100115 Firefox/3.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.1.8) Gecko/20100216 Lightning/1.0b1 Thunderbird/3.0.2

Even if the bug with condstore resulting in unexpected unread mails is fixed, the size of a message folder is still wrong calculated. 

Reproducible: Always

Steps to Reproduce:
1. ensure that condstore is enabled
2. enable the "size"-column in the folder column on the left
3. enter a folder
Actual Results:  
Wrong foldersize is shown: at my accounts often under 10 KB even if there are more than 3.000 mails in the account with huge attachments

Expected Results:  
Actual foldersize after having condstore disabled once more: about 60 MB

Thunderbird 3.0.2 connected to Dovecot 1.2.10
Ah, yeah - thx for filing this. No one has filed it before, probably because you need an extension to see the folder size.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee: nobody → bienvenu
Summary: Condstore still returns wrong folder size → IMAP Condstore server results in wrong folder size
Attached patch proposed fix (obsolete) — Splinter Review
Don't update folder size if we're a condstore partial fetch.

Instead of doing checks for partialUIDFetch for every message, I decided to just do one at the end, since in the vast majority of the passes through this loop, partialUIDFetch will be false. I use a PRUint64 to prepare for the day where we handle IMAP folders > 4GB correctly here, though that change is beyond the scope of this bug (I'll file a follow-on fix for that)
Attachment #428948 - Flags: superreview?(neil)
Attachment #428948 - Flags: review?(neil)
 Bug 548602 filed for 64 bit folder size issue.
Comment on attachment 428948 [details] [diff] [review]
proposed fix

I don't have CONDSTORE so I can't really test this.

>     if (NS_SUCCEEDED(dbHdr->GetMessageSize(&messageSize)))
>-      mFolderSize += messageSize;
>+      newFolderSize += messageSize;
Worth doing this only for non-partial fetches?

>+  if (!partialUIDFetch && newFolderSize != oldFolderSize)
>+  {
>+    mFolderSize = newFolderSize;
>     NotifyIntPropertyChanged(kFolderSizeAtom, oldFolderSize, mFolderSize);
I thought the use of oldFolderSize was confusing. Maybe use mFolderSize in the condition, then have an oldFolderSize temporary inside this block?
(In reply to comment #4)
> (From update of attachment 428948 [details] [diff] [review])
> I don't have CONDSTORE so I can't really test this.
> 
> >     if (NS_SUCCEEDED(dbHdr->GetMessageSize(&messageSize)))
> >-      mFolderSize += messageSize;
> >+      newFolderSize += messageSize;
> Worth doing this only for non-partial fetches?

I think it's worth not checking the boolean, since the vast majority of the time through this loop, it will be false.

> 
> >+  if (!partialUIDFetch && newFolderSize != oldFolderSize)
> >+  {
> >+    mFolderSize = newFolderSize;
> >     NotifyIntPropertyChanged(kFolderSizeAtom, oldFolderSize, mFolderSize);
> I thought the use of oldFolderSize was confusing. Maybe use mFolderSize in the
> condition, then have an oldFolderSize temporary inside this block?

that's a thought - I'll do that.
Attached patch fix addressing comment (obsolete) — Splinter Review
gets rid of temp oldFolderSize variable...
Attachment #428948 - Attachment is obsolete: true
Attachment #428975 - Flags: superreview?(neil)
Attachment #428975 - Flags: review?(neil)
Attachment #428948 - Flags: superreview?(neil)
Attachment #428948 - Flags: review?(neil)
Comment on attachment 428975 [details] [diff] [review]
fix addressing comment

>-  if (oldFolderSize != mFolderSize)
>-    NotifyIntPropertyChanged(kFolderSizeAtom, oldFolderSize, mFolderSize);
>+  if (!partialUIDFetch && newFolderSize != mFolderSize)
>+  {
>+    NotifyIntPropertyChanged(kFolderSizeAtom, mFolderSize,
>+                            (PRUint32) newFolderSize);
>+    mFolderSize = newFolderSize;
>+  }
The old code obviously updated the folder size before notifying. Whether this is a problem depends on how you want to notify for a 64-bit folder size changing; are you going to create a new notification, or fire the old notification and expect consumers to read the new value? Note that the only caller of NotifyIntPropertyChanged that fires the notification first is ironically SetSizeOnDisk, which has one caller, which passes the current size!
(In reply to comment #7)

> The old code obviously updated the folder size before notifying. Whether this
> is a problem depends on how you want to notify for a 64-bit folder size
> changing; are you going to create a new notification, or fire the old
> notification and expect consumers to read the new value? Note that the only
> caller of NotifyIntPropertyChanged that fires the notification first is
> ironically SetSizeOnDisk, which has one caller, which passes the current size!

yeah, you're right - I need the temporary var.
I'm either going to add a new notification, or evilly make NotifyIntPropertyChanged take a 64 bit int.
Attachment #428975 - Attachment is obsolete: true
Attachment #429015 - Flags: superreview?(neil)
Attachment #429015 - Flags: review?(neil)
Attachment #428975 - Flags: superreview?(neil)
Attachment #428975 - Flags: review?(neil)
Depends on: 436151
Whiteboard: [gs]
Attachment #429015 - Flags: superreview?(neil)
Attachment #429015 - Flags: superreview+
Attachment #429015 - Flags: review?(neil)
Attachment #429015 - Flags: review+
fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
is it correct to cite this bug in http://gsfn.us/t/ogo5 ? (not sure if it was me or someone else)

and do the consequences of this bug justify pushing into 3.0.x?
blocking-thunderbird3.0: --- → ?
Attachment #429015 - Flags: approval-thunderbird3.0.6+
blocking-thunderbird3.0: ? → needed
Target Milestone: --- → Thunderbird 3.1b2
Comment on attachment 429015 [details] [diff] [review]
make sure size is right before sending notification

Didn't make 3.0.6, will re-consider for 3.0.7.
Attachment #429015 - Flags: approval-thunderbird3.0.6+ → approval-thunderbird3.0.7?
blocking-thunderbird3.0: needed → ---
Comment on attachment 429015 [details] [diff] [review]
make sure size is right before sending notification

Having thought about the risk/benefit and the fact that we know most people using the extension aren't on 3.0.x, I've decided not to take this - the fix is in 3.1.x which we're offering for updates at the moment.
Attachment #429015 - Flags: approval-thunderbird3.0.7? → approval-thunderbird3.0.7-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: