X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=261be01604cb5bffa34143ca9f1d6212d64725e1;hp=23ddd4ae1314b2186b7839364b06cc0d25b5a575;hb=ba12bf1f2625a34f960502a06ba8907445ef5257;hpb=7a215c2de81e95798ecadd982eecf05e647c3988 diff --git a/lib/database.cc b/lib/database.cc index 23ddd4ae..261be016 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -587,6 +587,40 @@ timestamp_db_key (const char *key) return strdup (key); } +/* Given a legal 'path' for the database, return the relative path. + * + * The return value will be a pointer to the originl path contents, + * and will be either the original string (if 'path' was relative) or + * a portion of the string (if path was absolute and begins with the + * database path). + */ +const char * +_notmuch_database_relative_path (notmuch_database_t *notmuch, + const char *path) +{ + const char *db_path, *relative; + unsigned int db_path_len; + + db_path = notmuch_database_get_path (notmuch); + db_path_len = strlen (db_path); + + relative = path; + + if (*relative == '/') { + while (*relative == '/' && *(relative+1) == '/') + relative++; + + if (strncmp (relative, db_path, db_path_len) == 0) + { + relative += db_path_len; + while (*relative == '/') + relative++; + } + } + + return relative; +} + notmuch_status_t notmuch_database_set_timestamp (notmuch_database_t *notmuch, const char *key, time_t timestamp) @@ -855,12 +889,11 @@ _notmuch_database_link_message_to_children (notmuch_database_t *notmuch, * * We first look at 'message_file' and its link-relevant headers * (References and In-Reply-To) for message IDs. We also look in the - * database for existing message that reference 'message'.p + * database for existing message that reference 'message'. * - * The end result is to call _notmuch_message_add_thread_id with one - * or more thread IDs to which this message belongs, (including - * generating a new thread ID if necessary if the message doesn't - * connect to any existing threads). + * The end result is to call _notmuch_message_ensure_thread_id which + * generates a new thread ID if the message doesn't connect to any + * existing threads. */ static notmuch_status_t _notmuch_database_link_message (notmuch_database_t *notmuch,