Bug 320830 - ui shows old cached directory structure before first conection
Summary: ui shows old cached directory structure before first conection
Status: RESOLVED FIXED
Alias: None
Product: trojita
Classification: Applications
Component: IMAP (show other bugs)
Version: git
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: Trojita default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-06 19:48 UTC by Ronny Pfannschmidt
Modified: 2013-06-08 20:57 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ronny Pfannschmidt 2013-06-06 19:48:03 UTC
i had my imapd missconfigured on first connect,
trojita shows that directory structure on startup each time before it syncs with the server

Reproducible: Always

Steps to Reproduce:
1. start trojita

Actual Results:  
1. see old structure flicker

Expected Results:  
1. just see current structure
Comment 1 Caspar Schutijser 2013-06-08 15:22:46 UTC
I see this problem as well. I noticed because I changed my directory structure after I installed Trojita and indeed, it showed the old directory strucure when connecting to my mail server.

I did some research and I think the problem is related to the cache, Imap::Mailbox::SQLCache to be specific. In ~/.cache/flaksa.net/trojita/imap.cache.sqlite, in the "child_mailboxes" table, the names of the mailboxes are stored. In Imap::Mailbox::SQLCache, the "child_mailboxes" string appears a couple of times in SQL queries, but (if I didn't mis anything) only in CREATE TABLE, SELECT and INSERT OR REPLACE queries. My guess is that the mailboxes that do not exist anymore are not DELETEd and that might be the cause of this.
Comment 2 Thomas Lübking 2013-06-08 17:05:00 UTC
what about just connecting the autoexpansion to the connection established signal?
Comment 3 Jan Kundrát 2013-06-08 17:23:57 UTC
The problem is indeed in the caching layer, the old entries are not removed.

Auto-expanding all mailboxes is too evil (it's actually very strongly discouraged in multiple "how to write an IMAP client" howtos because you never know the depth of the tree) and will not fix this problem anyway.
Comment 4 Thomas Lübking 2013-06-08 17:39:33 UTC
I only meant the root layer (which, if not expanded, would hide the unsynced state) - not unfolding everything (eg. unfolding the [gmail] box takes a considerable time...)

Since trojita takes the visibility as trigger to sync the mailbox, this would have to be done a little different, eg. expand but before the bpx is synced, use a fake size and paint nothing and a throbber (wait animation) instead.
Comment 5 Jan Kundrát 2013-06-08 18:57:47 UTC
Unfortunately, what might be a good optimization for GMail does not work for other servers. For example, on my work account there are many top-level mailboxes (i.e. "Sent" is a sibling to INBOX, as are more folders for categorization like "dev" which contains "gentoo" and "kde" subfolders, the former containing "kde-pim" etc etc). Other servers enforce that all mailboxes must be nested below INBOX itself, so that it's "INBOX -> dev -> kde -> kde-pim", etc).

There's one more problem -- when the mailbox listing is fetched from the server, it replaces the list of mailboxes already shown (as determined from cache). This leads to a brief flicker (and a loss of current selection, etc) when you're on a slow network. This has been overdue for a long time, see https://projects.flaska.net/issues/25; it's not exactly trivial to fix because that will involve solving https://projects.flaska.net/issues/455 as well.

Anyway, patch for broken cache behavior is at https://git.reviewboard.kde.org/r/110896/. Thanks to Caspar for tracking down the problem -- that was a big help, I actually knew about this bug for months, but did nothing about it.
Comment 6 Jan Kundrát 2013-06-08 20:57:24 UTC
Git commit 0ea69817878ebb3093fe50313cc0cb6b60b785d2 by Jan Kundrát.
Committed on 08/06/2013 at 20:50.
Pushed by jkt into branch 'master'.

cache: Remove mailboxes when they are, well, removed

Thanks to Caspar for the initial troubleshooting -- I've known about this bug
for several months, but haven't bothered to fix it properly. His analysis
pinpointed the root cause of the problem and made it easy to fix this.
REVIEW: 110896

M  +11   -0    src/Imap/Model/SQLCache.cpp
M  +1    -0    src/Imap/Model/SQLCache.h
A  +95   -0    tests/tests/test_SqlCache/test_SqlCache.cpp     [License: GPL (v2/3)]
A  +48   -0    tests/tests/test_SqlCache/test_SqlCache.h     [License: GPL (v2/3)]
A  +3    -0    tests/tests/test_SqlCache/test_SqlCache.pro
M  +2    -1    tests/tests/tests.pro

http://commits.kde.org/trojita/0ea69817878ebb3093fe50313cc0cb6b60b785d2