]> git.notmuchmail.org Git - notmuch/blobdiff - lib/database.cc
lib: add NOTMUCH_STATUS_NO_DATABASE
[notmuch] / lib / database.cc
index 248d1dc27a89dad5c8759e02e4c9758d3f941e3c..96458f6ff104a18ba28d59929b7597cf284feeec 100644 (file)
@@ -293,12 +293,22 @@ notmuch_status_to_string (notmuch_status_t status)
        return "Operation requires a database upgrade";
     case NOTMUCH_STATUS_PATH_ERROR:
        return "Path supplied is illegal for this function";
+    case NOTMUCH_STATUS_IGNORED:
+       return "Argument was ignored";
+    case NOTMUCH_STATUS_ILLEGAL_ARGUMENT:
+       return "Illegal argument for function";
     case NOTMUCH_STATUS_MALFORMED_CRYPTO_PROTOCOL:
        return "Crypto protocol missing, malformed, or unintelligible";
     case NOTMUCH_STATUS_FAILED_CRYPTO_CONTEXT_CREATION:
        return "Crypto engine initialization failure";
     case NOTMUCH_STATUS_UNKNOWN_CRYPTO_PROTOCOL:
        return "Unknown crypto protocol";
+    case NOTMUCH_STATUS_NO_CONFIG:
+       return "No configuration file found";
+    case NOTMUCH_STATUS_NO_DATABASE:
+       return "No database found";
+    case NOTMUCH_STATUS_DATABASE_EXISTS:
+       return "Database exists, not recreated";
     default:
     case NOTMUCH_STATUS_LAST_STATUS:
        return "Unknown error status value";
@@ -610,11 +620,12 @@ notmuch_database_compact_db (notmuch_database_t *notmuch,
                             void *closure)
 {
     void *local;
-    char *notmuch_path, *xapian_path, *compact_xapian_path;
+    const char *xapian_path, *compact_xapian_path;
     const char *path;
     notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
     struct stat statbuf;
     bool keep_backup;
+    char *message;
 
     ret = _notmuch_database_ensure_writable (notmuch);
     if (ret)
@@ -628,15 +639,9 @@ notmuch_database_compact_db (notmuch_database_t *notmuch,
     if (! local)
        return NOTMUCH_STATUS_OUT_OF_MEMORY;
 
-    if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) {
-       ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
-       goto DONE;
-    }
-
-    if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) {
-       ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
+    ret = _notmuch_choose_xapian_path (local, path, &xapian_path, &message);
+    if (ret)
        goto DONE;
-    }
 
     if (! (compact_xapian_path = talloc_asprintf (local, "%s.compact", xapian_path))) {
        ret = NOTMUCH_STATUS_OUT_OF_MEMORY;