pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
700 stars 163 forks source link

Make notmuch db location logic match upstream #1495

Open kirelagin opened 4 years ago

kirelagin commented 4 years ago

Fixes #1396.


I am sorry, I have no idea how to write tests in Python, in particular, how to define helper constants in them. I suspect I should have put them not at the toplevel, but in the class, but I don’t know how to do that, please, help.

kirelagin commented 4 years ago

Actually, I wish this code was in the bindings or in the C functions that bindings go through.

pazz commented 4 years ago

I agree: this is something that the notmuch bindings should expose and we should not re-implement if it already exists as a (c) library function.

I don't have time to look into this at the moment, but perhaps you could write to the notmuch list if this is not already in the bindings and ask why not, or propose a change to the bindings before you come back here to propose a PR that simply uses the bindings? I believe that'd be the cleanest solution.

kirelagin commented 4 years ago

This problem is that this logic is implemented in notmuch_config_open and the only use of this function is directly in main. As far as I can tell, there is nothing in bindings for working with the configuration, so exposing this logic from the C code will require quite a bit of restructuring. I wouldn’t hope that this is something that will be trivial to do.

pazz commented 4 years ago

I've been thinking about this again and it seems to be quite a big patch for a minimal change. In fact we can assume that the notmuch config does set the path variable, so there is really no need to set an explicit default value. Secondly, why not sumply replace this line with

indexpath = os.path.abspath(settings.get_notmuch_setting('database', 'path'))

This will replace any relative path by its absolute path.