mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-02-17 23:53:15 +01:00
lib: Perform the same transformation to _notmuch_database_filename_to_direntry
Now _notmuch_database_filename_to_direntry takes a flags argument and can indicate if the necessary directory documents do not exist. Again, callers have been updated, but retain their original behavior.
This commit is contained in:
parent
0c950146a1
commit
67ae2377a9
3 changed files with 16 additions and 11 deletions
|
@ -1248,13 +1248,16 @@ _notmuch_database_get_directory_path (void *ctx,
|
||||||
* database path), return a new string (with 'ctx' as the talloc
|
* database path), return a new string (with 'ctx' as the talloc
|
||||||
* owner) suitable for use as a direntry term value.
|
* owner) suitable for use as a direntry term value.
|
||||||
*
|
*
|
||||||
* The necessary directory documents will be created in the database
|
* If (flags & NOTMUCH_FIND_CREATE), the necessary directory documents
|
||||||
* as needed.
|
* will be created in the database as needed. Otherwise, if the
|
||||||
|
* necessary directory documents do not exist, this sets
|
||||||
|
* *direntry to NULL and returns NOTMUCH_STATUS_SUCCESS.
|
||||||
*/
|
*/
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
_notmuch_database_filename_to_direntry (void *ctx,
|
_notmuch_database_filename_to_direntry (void *ctx,
|
||||||
notmuch_database_t *notmuch,
|
notmuch_database_t *notmuch,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
|
notmuch_find_flags_t flags,
|
||||||
char **direntry)
|
char **direntry)
|
||||||
{
|
{
|
||||||
const char *relative, *directory, *basename;
|
const char *relative, *directory, *basename;
|
||||||
|
@ -1268,10 +1271,12 @@ _notmuch_database_filename_to_direntry (void *ctx,
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
status = _notmuch_database_find_directory_id (notmuch, directory, NOTMUCH_FIND_CREATE,
|
status = _notmuch_database_find_directory_id (notmuch, directory, flags,
|
||||||
&directory_id);
|
&directory_id);
|
||||||
if (status)
|
if (status || directory_id == (unsigned int)-1) {
|
||||||
|
*direntry = NULL;
|
||||||
return status;
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
*direntry = talloc_asprintf (ctx, "%u:%s", directory_id, basename);
|
*direntry = talloc_asprintf (ctx, "%u:%s", directory_id, basename);
|
||||||
|
|
||||||
|
@ -1892,8 +1897,8 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
|
||||||
local = talloc_new (notmuch);
|
local = talloc_new (notmuch);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
status = _notmuch_database_filename_to_direntry (local, notmuch,
|
status = _notmuch_database_filename_to_direntry (
|
||||||
filename, &direntry);
|
local, notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);
|
||||||
if (status)
|
if (status)
|
||||||
goto DONE;
|
goto DONE;
|
||||||
|
|
||||||
|
|
|
@ -495,9 +495,8 @@ _notmuch_message_add_filename (notmuch_message_t *message,
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
status = _notmuch_database_filename_to_direntry (local,
|
status = _notmuch_database_filename_to_direntry (
|
||||||
message->notmuch,
|
local, message->notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);
|
||||||
filename, &direntry);
|
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
@ -541,8 +540,8 @@ _notmuch_message_remove_filename (notmuch_message_t *message,
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
Xapian::TermIterator i, last;
|
Xapian::TermIterator i, last;
|
||||||
|
|
||||||
status = _notmuch_database_filename_to_direntry (local, message->notmuch,
|
status = _notmuch_database_filename_to_direntry (
|
||||||
filename, &direntry);
|
local, message->notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,7 @@ notmuch_status_t
|
||||||
_notmuch_database_filename_to_direntry (void *ctx,
|
_notmuch_database_filename_to_direntry (void *ctx,
|
||||||
notmuch_database_t *notmuch,
|
notmuch_database_t *notmuch,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
|
notmuch_find_flags_t flags,
|
||||||
char **direntry);
|
char **direntry);
|
||||||
|
|
||||||
/* directory.cc */
|
/* directory.cc */
|
||||||
|
|
Loading…
Add table
Reference in a new issue