Giter Site home page Giter Site logo

Comments (24)

nicolas33 avatar nicolas33 commented on May 18, 2024 1

Yes! Exactly this.

Ok, thanks for your insistence. I did not understand your point soon because I was focused on how the file is constructed instead of the result. It's obvious that -a must not erase the entries of the other accounts. The solving is easy but we definitely won't connect to the other remotes.

So, mbnames should build intermediate mbnames in <metadata>/mbnames in a per-account basis. At the end of the sync of each account, the intermediate file is updated.

Then, the real target can be built by concatenation of all the intermediate mbnames. This operation is triggered at the end of the full sync if incremental option is disabled and at the end of the sync of each account otherwise.

We might want to add a purge option in the mbnames section to remove any intermediate file not in the accounts list.

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

I'm not using mbnames myself but I agree that having this outside any account section or outside the general section is wrong.

Is it possible to workaround this issue by using the sort_keyfunc?

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

I don't get why mbnames would have to be constructed for accounts not being synced.

from offlineimap.

lahwaacz avatar lahwaacz commented on May 18, 2024

Because mailbox names are global file (as expected by e.g. mutt), so running offlineimap should always produce the same file, regardless of which accounts are being synced. I strongly recommend to reopen this bug.

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

Please, provide a sample of the current behaviour and what you would expect.

from offlineimap.

lahwaacz avatar lahwaacz commented on May 18, 2024

offlineimap's config snippet:

[mbnames]
enabled = yes
filename = ~/mailboxes
header = "mailboxes "
peritem = "+%(accountname)s/%(foldername)s"
sep = " "
footer = "\n"

[Account foo]
...

[Account bar]
...

Testing current behaviour:

$ offlineimap -o -u quiet -a foo
$ cat ~/mailboxes 
mailboxes "+foo/INBOX" "+foo/drafts" "+foo/sent" "+foo/spam" "+foo/trash"
$ offlineimap -o -u quiet -a bar
$ cat ~/mailboxes 
mailboxes "+bar/INBOX" "+bar/drafts" "+bar/sent" "+bar/spam" "+bar/trash"

Expected result for both cases:

mailboxes "+bar/INBOX" "+bar/drafts" "+bar/sent" "+bar/spam" "+bar/trash" "+foo/INBOX" "+foo/drafts" "+foo/sent" "+foo/spam" "+foo/trash"

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

Why not run offlineimap -o -u quiet?

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

Actually, this would be wrong to make any wite for accounts not requested at CLI.

from offlineimap.

lahwaacz avatar lahwaacz commented on May 18, 2024

Why not run offlineimap -o -u quiet?

For the same reason why quick specificaton of accounts on the command-line exists in the first place - to focus on doing the most important task as fast as possible. Syncing all accounts at once might take a long time, while users might need to quickly sync one specific account, for example via hooks for currently open mailbox in mutt.

Actually, this would be wrong to make any wite for accounts not requested at CLI.

I could understand a problem with not respecting the accounts list in the [general] section of the config, but I don't see a problem with taking all accounts from the config regardless of the CLI options. Please elaborate why this is such a big problem.

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

As soon as we would implement writes for accounts not requested at CLI, users will complain about unexpected directory creations.

I still don't get exactly why you need the creation of (empty) folders for maildirs not going to be synced.

I wonder this use case is too much specific and does not worth the code complexity to be added for this edge-case feature.

Please, don't get me wrong. I'm not offending you and I'm not invalidating your use case. I'm pointing out that this specific use case is marginal enough and would introduce unexpected behaviour for most users to worth the change.

from offlineimap.

lahwaacz avatar lahwaacz commented on May 18, 2024

The expected behaviour is not that all the directories would be created, but they would be written to the mailbox names file (set with the filename option in [mbnames]). It is the client's responsibility to handle non-existent directories in a sane way; in my use case all directories already exist due to previous sync of all the accounts.

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

Yes, sorry for not being clear. Writing mbnames to the filename for non-synced accounts is wrong because entries would be created for non-existing folders. mbnames is supposed to map to the local maildir of the synced folders.

We are NOT supposed to connect to a remote account if we are not requested to sync it.

in my use case all directories already exist due to previous sync of all the accounts.

So, should be the mbname entries.

from offlineimap.

lahwaacz avatar lahwaacz commented on May 18, 2024

mbnames is supposed to map to the local maildir of the synced folders.

I think this is where we'll disagree. From the clients' point of view, e.g. Mutt reading the mbnames file, it expects all folders that currently exist locally, even if they are not synced most recently. Now it's up to offlineimap to ensure that this expectation is fulfilled in all its operation.

We are NOT supposed to connect to a remote account if we are not requested to sync it.

Now I can see why the implementation seems too complex to you. I agree that connecting to remote accounts that are not being synced is wrong, but you don't have to do that for this functionality. For example, the last-synced folders are already cached in the Repository-<name>-local/FolderValidity/<folder name> files. For accounts that are not being synced, this is a read-only operation.

from offlineimap.

dolohow avatar dolohow commented on May 18, 2024

What about switch --create-mbnames?

And also I agree with @nicolas33, we should not create directories of other accounts when syncing only specific with -a switch.

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

From the clients' point of view, e.g. Mutt reading the mbnames file, it expects all folders that currently exist locally, even if they are not synced most recently.

At the end of the sync, the mapping is updated. We can't write the mbnames before we know the local maildirs to create. We know this at sync time.

the last-synced folders are already cached in the Repository--local/FolderValidity/ files. For accounts that are not being synced, this is a read-only operation.

I don't get why it is required to update the mbnames after the lastest sync since it was already updated at the end of the latest sync.

If this feature only requires to read the local cache, I think a little shell/lua/whatever script can easily do the job. Hence, I'm still not convince we should implement this in offlineimap. I'd be delighted that any user request us to add its own script in the contrib/ directory of the official sources. Even if I don't get how it's usefull.

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

Hmm, I guess I'm getting your issue. When used with -a, is offlineimap erasing or clearing the entries of the other accounts?

from offlineimap.

lahwaacz avatar lahwaacz commented on May 18, 2024

Hmm, I guess I'm getting your issue. Is offlineimap erasing or clearing the entries of the other accounts when used with -a?

Yes! Exactly this. Please take a look at this post again, it's all there: after offlineimap -o -u quiet -a foo the mbnames file contains entries only for the foo account, regardless of the previous content, sync or anything. That means that you can't effectively use the -a option with different accounts along with the [mbnames] section enabled, because the writes to the mbnames file will overwrite each other.

When you've finally got it, can this issue be finally reopened to acknowledge it as a valid bug?

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

@lahwaacz Could you test https://github.com/nicolas33/offlineimap/tree/ns/mbnames please?

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

I did some basic tests, here.

Notice you don't need to create folders to check updates are done right. Instead, you might want to check the date and content of the files in the cache (<metadata>/mbnames) and the content of your mbnames target file.

from offlineimap.

lahwaacz avatar lahwaacz commented on May 18, 2024

I think that will fix the issue. Is there a specific reason to use yaml and require a 3rd party module instead of using e.g. json from the standard library?

from offlineimap.

dolohow avatar dolohow commented on May 18, 2024

Is there a specific reason to use yaml and require a 3rd party module instead of using e.g. json from the standard library?

That is a good question.

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

Is there a specific reason to use yaml and require a 3rd party module instead of using e.g. json from the standard library?

That is a good question.

I second that. I didn't know json is in the standard library. Will change that soon. Good catch!

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

https://github.com/nicolas33/offlineimap/tree/ns/mbnames-2

from offlineimap.

nicolas33 avatar nicolas33 commented on May 18, 2024

Fixed.

from offlineimap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.