mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-28 05:34:11 +01:00
Merge branch 'release'
This commit is contained in:
commit
e7bb7919a2
3 changed files with 131 additions and 10 deletions
|
@ -433,6 +433,8 @@ notmuch_database_open_verbose (const char *path,
|
||||||
* @retval NOTMUCH_STATUS_NULL_POINTER: The given \a database
|
* @retval NOTMUCH_STATUS_NULL_POINTER: The given \a database
|
||||||
* argument is NULL.
|
* argument is NULL.
|
||||||
*
|
*
|
||||||
|
* @retval NOTMUCH_STATUS_NO_CONFIG: No config file was found. Fatal.
|
||||||
|
*
|
||||||
* @retval NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory.
|
* @retval NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory.
|
||||||
*
|
*
|
||||||
* @retval NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to open the
|
* @retval NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to open the
|
||||||
|
@ -458,6 +460,9 @@ notmuch_database_open_with_config (const char *database_path,
|
||||||
*
|
*
|
||||||
* For description of arguments, @see notmuch_database_open_with_config
|
* For description of arguments, @see notmuch_database_open_with_config
|
||||||
*
|
*
|
||||||
|
* For errors other then NO_DATABASE and NO_CONFIG, *database is set to
|
||||||
|
* NULL.
|
||||||
|
*
|
||||||
* @retval NOTMUCH_STATUS_SUCCESS: Successfully loaded configuration.
|
* @retval NOTMUCH_STATUS_SUCCESS: Successfully loaded configuration.
|
||||||
*
|
*
|
||||||
* @retval NOTMUCH_STATUS_NO_CONFIG: No config file was loaded. Not fatal.
|
* @retval NOTMUCH_STATUS_NO_CONFIG: No config file was loaded. Not fatal.
|
||||||
|
@ -489,6 +494,9 @@ notmuch_database_load_config (const char *database_path,
|
||||||
*
|
*
|
||||||
* For description of arguments, @see notmuch_database_open_with_config
|
* For description of arguments, @see notmuch_database_open_with_config
|
||||||
*
|
*
|
||||||
|
* In case of any failure, this function returns an error status and
|
||||||
|
* sets *database to NULL.
|
||||||
|
*
|
||||||
* @retval NOTMUCH_STATUS_SUCCESS: Successfully created the database.
|
* @retval NOTMUCH_STATUS_SUCCESS: Successfully created the database.
|
||||||
*
|
*
|
||||||
* @retval NOTMUCH_STATUS_DATABASE_EXISTS: Database already exists, not created
|
* @retval NOTMUCH_STATUS_DATABASE_EXISTS: Database already exists, not created
|
||||||
|
|
30
lib/open.cc
30
lib/open.cc
|
@ -396,8 +396,6 @@ _finish_open (notmuch_database_t *notmuch,
|
||||||
" has a newer database format version (%u) than supported by this\n"
|
" has a newer database format version (%u) than supported by this\n"
|
||||||
" version of notmuch (%u).\n",
|
" version of notmuch (%u).\n",
|
||||||
database_path, version, NOTMUCH_DATABASE_VERSION));
|
database_path, version, NOTMUCH_DATABASE_VERSION));
|
||||||
notmuch_database_destroy (notmuch);
|
|
||||||
notmuch = NULL;
|
|
||||||
status = NOTMUCH_STATUS_FILE_ERROR;
|
status = NOTMUCH_STATUS_FILE_ERROR;
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
}
|
||||||
|
@ -414,8 +412,6 @@ _finish_open (notmuch_database_t *notmuch,
|
||||||
" requires features (%s)\n"
|
" requires features (%s)\n"
|
||||||
" not supported by this version of notmuch.\n",
|
" not supported by this version of notmuch.\n",
|
||||||
database_path, incompat_features));
|
database_path, incompat_features));
|
||||||
notmuch_database_destroy (notmuch);
|
|
||||||
notmuch = NULL;
|
|
||||||
status = NOTMUCH_STATUS_FILE_ERROR;
|
status = NOTMUCH_STATUS_FILE_ERROR;
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
}
|
||||||
|
@ -489,8 +485,6 @@ _finish_open (notmuch_database_t *notmuch,
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
IGNORE_RESULT (asprintf (&message, "A Xapian exception occurred opening database: %s\n",
|
IGNORE_RESULT (asprintf (&message, "A Xapian exception occurred opening database: %s\n",
|
||||||
error.get_msg ().c_str ()));
|
error.get_msg ().c_str ()));
|
||||||
notmuch_database_destroy (notmuch);
|
|
||||||
notmuch = NULL;
|
|
||||||
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
DONE:
|
DONE:
|
||||||
|
@ -559,10 +553,13 @@ notmuch_database_open_with_config (const char *database_path,
|
||||||
free (message);
|
free (message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status && notmuch) {
|
||||||
|
notmuch_database_destroy (notmuch);
|
||||||
|
notmuch = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (database)
|
if (database)
|
||||||
*database = notmuch;
|
*database = notmuch;
|
||||||
else
|
|
||||||
talloc_free (notmuch);
|
|
||||||
|
|
||||||
if (notmuch)
|
if (notmuch)
|
||||||
notmuch->open = true;
|
notmuch->open = true;
|
||||||
|
@ -717,10 +714,16 @@ notmuch_database_create_with_config (const char *database_path,
|
||||||
else
|
else
|
||||||
free (message);
|
free (message);
|
||||||
}
|
}
|
||||||
|
if (status && notmuch) {
|
||||||
|
notmuch_database_destroy (notmuch);
|
||||||
|
notmuch = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (database)
|
if (database)
|
||||||
*database = notmuch;
|
*database = notmuch;
|
||||||
else
|
|
||||||
talloc_free (notmuch);
|
if (notmuch)
|
||||||
|
notmuch->open = true;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,6 +871,13 @@ notmuch_database_load_config (const char *database_path,
|
||||||
if (status_string)
|
if (status_string)
|
||||||
*status_string = message;
|
*status_string = message;
|
||||||
|
|
||||||
|
if (status &&
|
||||||
|
status != NOTMUCH_STATUS_NO_DATABASE
|
||||||
|
&& status != NOTMUCH_STATUS_NO_CONFIG) {
|
||||||
|
notmuch_database_destroy (notmuch);
|
||||||
|
notmuch = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (database)
|
if (database)
|
||||||
*database = notmuch;
|
*database = notmuch;
|
||||||
|
|
||||||
|
|
|
@ -849,4 +849,107 @@ zzzafter afterval
|
||||||
EOF
|
EOF
|
||||||
test_expect_equal_file EXPECTED OUTPUT
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
cat <<EOF > c_head3
|
||||||
|
#include <notmuch-test.h>
|
||||||
|
int main (int argc, char **argv) {
|
||||||
|
notmuch_status_t stat;
|
||||||
|
notmuch_database_t *db = NULL;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF > c_tail3
|
||||||
|
printf("db == NULL: %d\n", db == NULL);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_begin_subtest "open: database set to null on missing config"
|
||||||
|
cat c_head3 - c_tail3 <<'EOF' | test_C ${MAIL_DIR}
|
||||||
|
notmuch_status_t st = notmuch_database_open_with_config(argv[1],
|
||||||
|
NOTMUCH_DATABASE_MODE_READ_ONLY,
|
||||||
|
"/nonexistent", NULL, &db, NULL);
|
||||||
|
EOF
|
||||||
|
cat <<EOF> EXPECTED
|
||||||
|
== stdout ==
|
||||||
|
db == NULL: 1
|
||||||
|
== stderr ==
|
||||||
|
EOF
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
test_begin_subtest "open: database set to null on missing config (env)"
|
||||||
|
old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
|
||||||
|
NOTMUCH_CONFIG="/nonexistent"
|
||||||
|
cat c_head3 - c_tail3 <<'EOF' | test_C ${MAIL_DIR}
|
||||||
|
notmuch_status_t st = notmuch_database_open_with_config(argv[1],
|
||||||
|
NOTMUCH_DATABASE_MODE_READ_ONLY,
|
||||||
|
NULL, NULL, &db, NULL);
|
||||||
|
EOF
|
||||||
|
NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
|
||||||
|
cat <<EOF> EXPECTED
|
||||||
|
== stdout ==
|
||||||
|
db == NULL: 1
|
||||||
|
== stderr ==
|
||||||
|
EOF
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
test_begin_subtest "create: database set to null on missing config"
|
||||||
|
cat c_head3 - c_tail3 <<'EOF' | test_C ${MAIL_DIR} "/nonexistent"
|
||||||
|
notmuch_status_t st = notmuch_database_create_with_config(argv[1],argv[2], NULL, &db, NULL);
|
||||||
|
EOF
|
||||||
|
cat <<EOF> EXPECTED
|
||||||
|
== stdout ==
|
||||||
|
db == NULL: 1
|
||||||
|
== stderr ==
|
||||||
|
EOF
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
test_begin_subtest "create: database set to null on missing config (env)"
|
||||||
|
old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
|
||||||
|
NOTMUCH_CONFIG="/nonexistent"
|
||||||
|
cat c_head3 - c_tail3 <<'EOF' | test_C ${MAIL_DIR}
|
||||||
|
notmuch_status_t st = notmuch_database_create_with_config(argv[1],
|
||||||
|
NULL, NULL, &db, NULL);
|
||||||
|
EOF
|
||||||
|
NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
|
||||||
|
cat <<EOF> EXPECTED
|
||||||
|
== stdout ==
|
||||||
|
db == NULL: 1
|
||||||
|
== stderr ==
|
||||||
|
EOF
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
test_begin_subtest "load_config: database set non-null on missing config"
|
||||||
|
cat c_head3 - c_tail3 <<'EOF' | test_C ${MAIL_DIR} "/nonexistent"
|
||||||
|
notmuch_status_t st = notmuch_database_load_config(argv[1],argv[2], NULL, &db, NULL);
|
||||||
|
EOF
|
||||||
|
cat <<EOF> EXPECTED
|
||||||
|
== stdout ==
|
||||||
|
db == NULL: 0
|
||||||
|
== stderr ==
|
||||||
|
EOF
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
test_begin_subtest "load_config: database non-null on missing config (env)"
|
||||||
|
old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
|
||||||
|
NOTMUCH_CONFIG="/nonexistent"
|
||||||
|
cat c_head3 - c_tail3 <<'EOF' | test_C ${MAIL_DIR}
|
||||||
|
notmuch_status_t st = notmuch_database_load_config(argv[1], NULL, NULL, &db, NULL);
|
||||||
|
EOF
|
||||||
|
NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
|
||||||
|
cat <<EOF> EXPECTED
|
||||||
|
== stdout ==
|
||||||
|
db == NULL: 0
|
||||||
|
== stderr ==
|
||||||
|
EOF
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
test_begin_subtest "load_config: database set to NULL on fatal error"
|
||||||
|
cat c_head3 - c_tail3 <<'EOF' | test_C
|
||||||
|
notmuch_status_t st = notmuch_database_load_config("relative", NULL, NULL, &db, NULL);
|
||||||
|
EOF
|
||||||
|
cat <<EOF> EXPECTED
|
||||||
|
== stdout ==
|
||||||
|
db == NULL: 1
|
||||||
|
== stderr ==
|
||||||
|
EOF
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue