Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate folder entries in the database #1220

Closed
ghostrider72 opened this issue Mar 27, 2016 · 18 comments
Closed

Duplicate folder entries in the database #1220

ghostrider72 opened this issue Mar 27, 2016 · 18 comments
Labels
type: bug Something is causing incorrect behavior or errors

Comments

@ghostrider72
Copy link

I installed the latest k9 mail version taken from the play store on both my identical phones (two elephone trunks with Android 5.1) but in one of them k9 is showing a very strange behavior:
in fact, there are two trash folders and even if I check on Gmail desktop via web, everything is normal.
So I don't know what's causing this issue and need your help.
Thanks and happy Easter!

@philipwhiuk philipwhiuk added the type: bug Something is causing incorrect behavior or errors label Mar 28, 2016
@philipwhiuk
Copy link
Contributor

I found this. I don't know what causes it, but what happens is we get back two entries for the same LocalFolder when fetching the list.

I added a temporary fix to my dev code here (the outer if block): https://github.com/philipwhiuk/k-9/blob/master/k9mail/src/main/java/com/fsck/k9/activity/FolderList.java#L780

I don't really want to push it because it's not actually fixing the problem, just hiding it.

It looks like localStore.getPersonalNamespaces(false) is returning duplicates.

And that just does a DB query, so there's a database duplication issue somewhere. That's hard to easily debug, so there's some investigation to do.

Its only a visual thing, because they both return the same underlying instance. If we were passing a Set not a list we'd never have known.

@philipwhiuk philipwhiuk changed the title Duplicate trash folder only in one of my two phones! Duplicate folder entries in the database Mar 28, 2016
@ghostrider72
Copy link
Author

Thanks for the help but I must admit I understood nothing. Said in other words: is it a known problem? Is there any idea why it appears in one phone and not in the other?
Any way to fix it?
Thanks

@philipwhiuk
Copy link
Contributor

It's a problem I was vaguely aware of but hadn't written a bug for (mainly because I often hit bugs which are only present in unreleased code).

The analysis was mainly for me / another person who wants to try and fix it at some point (e.g. before the next stable release).

As for why it happens in only one phone, I don't know. It may be luck. It may be just a matter of time. Heck it may be possible you'll get three eventually :(

I think if you delete the account or possibly just 'Recreate data' the extra entries should go.

Can't promise they won't come back at some point until I know why it's being dupe'd though.

@ghostrider72
Copy link
Author

Ok, thanks. Would you please tell me where the "recreate data" is?

@philipwhiuk
Copy link
Contributor

Long-tap on the account in the accounts list.

@ghostrider72
Copy link
Author

Thanks a lot! It worked! Thank you so much!
I wish you a very pleasant day!

@philipwhiuk
Copy link
Contributor

In terms of fixing this:

We are clearly creating the same folder in the DB twice. folders.name should be a unique field. If it were enforced in the DB we'd throw an SQLException when the duplication occurs. We could add this and then fix based on the inevitable crashes but that's kind of bad UX.

There are two calls to create a DB entry, MessagingController.doRefreshRemote and LocalFolder.create. Both do check for pre-existence, but outside a DB lock.

I think the only reason this can occur is that they are running simultaneously. However there's lots of calls to create making it very difficult to work out exactly why this is.

One solution is just do a second check while we have the DB lock and silently return if it exists. We could optionally also log a stack of where this occurring for debugging purposes, but unless we add something like ACRA we're never going to know for 99% of cases that it's occurring.

@cketti
Copy link
Member

cketti commented Mar 30, 2016

We could make the code only throw for debug builds (use BuildConfig.DEBUG). That way we at least have a chance to catch it during development.

@lazarus477
Copy link

Could this be triggered by the Import settings feature?

@CEB1970
Copy link

CEB1970 commented Jun 16, 2017

Importing the same account settings twice can cause this problem. I just had the problem occur after importing my account settings twice. There were duplicate Outbox and Trash folders. I fixed it by deleting the account and then importing the account settings just once.

@chrisrapson
Copy link

I had 2 copies of the Outbox folder in a Gmail account. Recreate data warns that it is a "last resort", so I decided to just change the Folder Display Class to hide it instead.

@PCZeroNet
Copy link

Will we ever see this fixed? The recreate data does not help. As soon as mail is fetched the next time after doing so the duplicates re-appear.

@NicoPL
Copy link

NicoPL commented Jan 14, 2019

Similar issue for me.
On 3 different phones, with 3 different mailboxes when:

  • creating a new account to sync in imap
  • having the K9 app in French
  • on the server side, 5 folders named: Inbox, Drafts, Sent, Trash, spam

I get 12 folders, and only the Inbox seems to be correctly used:

  • Archive (Archive)
    -> folder in K9 only
  • Brouillons (Brouillons)
    -> means 'draft', folder in K9 only, used by K9
  • Corbeille (Corbeille)
    -> means 'trash', folder in K9 only, emails deleted in K9 end up in there
  • Envoyés (Envoyés)
    -> means 'sent', folder in K9 only, emails sent with K9 end up in there
  • Boîte de réception
    -> the real 'Inbox' folder on the server side, both used on the server side and by K9
  • Boîte d'envoi
    -> means 'sending box'
  • Pourriel (Pourriel)
    -> means 'spam', folder in K9 only
  • Drafts
    -> the real 'draft' folder on the server side, not used by K9
  • Junk
    -> no idea, not in the server side, not used by K9
  • Sent
    -> the real 'sent' folder on the server side, not used by K9
  • spam
    -> the real 'spam' folder on the server side, not used by K9
  • Trash
    -> the real 'trash' folder on the server side, not used by K9

I believe it's an error when mapping the folders, and may appear on translated versions of K9 only?

@cketti
Copy link
Member

cketti commented Feb 28, 2019

I believe this is no longer an issue with master.

@wiz0u
Copy link

wiz0u commented May 22, 2020

Had the problem with version 5.600
"Recreate data" solved it.

@nyetwurk
Copy link

nyetwurk commented Aug 1, 2020

Screenshot_20200801-141750.png

@nyetwurk
Copy link

nyetwurk commented Aug 1, 2020

After recreate data:

Screenshot_20200801-141946.png

@nyetwurk
Copy link

nyetwurk commented Aug 1, 2020

had to force quit and do it a third time
5.600

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something is causing incorrect behavior or errors
Projects
None yet
Development

No branches or pull requests

10 participants