Quoth Justus Winter on Feb 21 at 1:29 am: > Hi fellow notmuchrs, > > while going through the python bindings I recently came across the > following note in the documentation for the Database.get_directory > function [0]: > > ~~~ snip ~~~ > Warning > > This call needs a writable database in Database.MODE.READ_WRITE > mode. The underlying library will exit the program if this method is > used on a read-only database! > ~~~ snap ~~~
This is a bug and should be thought of as such. INTERNAL_ERROR should only be used for internal library inconsistencies (e.g., things that should never ever happen) and the fact that it's leaking out here (and easy to trigger) is simply a mistake. This hasn't been fixed because it derives from an interface flaw. What should notmuch_database_get_directory do on a read-only database? It's specified to *create* the directory document if it doesn't exist, which is the problem. We could of course bandage this up and make it return an error if you request a non-existent directory on a read-only database, but that's an inconsistent interface. I think we were hoping to tweak the interface so you can tell it whether or not you want to create the directory, independent of the database being read/write or read-only, but no one has gotten around to that. As always, patches welcome!