diff options
author | Carl Worth <cworth@cworth.org> | 2009-10-28 16:50:14 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-10-28 16:51:56 -0700 |
commit | a1135f0b7e67db7056a4ef02d61b8ad0ec46e88b (patch) | |
tree | 1ecece326675b8364b406c224838674c5b211d29 /notmuch.c | |
parent | fbf55bfe2fdcdf3773ba37a9921875530e94c7b3 (diff) |
Fix add_message and get_filename to strip/re-add the database path.
We now store only a relative path inside the database so the database
is not nicely relocatable.
Diffstat (limited to 'notmuch.c')
-rw-r--r-- | notmuch.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -531,6 +531,30 @@ setup_command (unused (int argc), unused (char *argv[])) free (default_path); } + /* Coerce th directory into an absolute directory name. */ + if (*mail_directory != '/') { + char *cwd, *absolute_mail_directory; + + cwd = getcwd (NULL, 0); + if (cwd == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + if (asprintf (&absolute_mail_directory, "%s/%s", + cwd, mail_directory) < 0) + { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + free (cwd); + free (mail_directory); + mail_directory = absolute_mail_directory; + + printf ("Abs: %s\n", mail_directory); + } + notmuch = notmuch_database_create (mail_directory); if (notmuch == NULL) { fprintf (stderr, "Failed to create new notmuch database at %s\n", |