From a1135f0b7e67db7056a4ef02d61b8ad0ec46e88b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 28 Oct 2009 16:50:14 -0700 Subject: 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. --- notmuch.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'notmuch.c') diff --git a/notmuch.c b/notmuch.c index 5a0ca5c9..757f09d7 100644 --- a/notmuch.c +++ b/notmuch.c @@ -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", -- cgit v1.2.3