mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 09:24:54 +01:00
lib/open: restore default database path of $HOME/mail
Although this default worked for "notmuch config get", it didn't work most other places. Restore the previous functionality, with the wrinkle that XDG locations will shadow $HOME/mail if they exist. This fixes a bug reported by Jack Kamm in id:87eeefdc8b.fsf@gmail.com
This commit is contained in:
parent
0e8795b28c
commit
b3258244c8
4 changed files with 42 additions and 7 deletions
19
lib/open.cc
19
lib/open.cc
|
@ -209,8 +209,25 @@ _choose_database_path (void *ctx,
|
|||
}
|
||||
}
|
||||
if (! *database_path) {
|
||||
notmuch_status_t status;
|
||||
|
||||
*database_path = _xdg_dir (ctx, "XDG_DATA_HOME", ".local/share", profile);
|
||||
*split = true;
|
||||
status = _db_dir_exists (*database_path, message);
|
||||
if (status) {
|
||||
*database_path = NULL;
|
||||
} else {
|
||||
*split = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (! *database_path) {
|
||||
notmuch_status_t status;
|
||||
|
||||
*database_path = talloc_asprintf (ctx, "%s/mail", getenv ("HOME"));
|
||||
status = _db_dir_exists (*database_path, message);
|
||||
if (status) {
|
||||
*database_path = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (*database_path == NULL) {
|
||||
|
|
|
@ -16,6 +16,7 @@ restore_config () {
|
|||
unset DATABASE_PATH
|
||||
unset NOTMUCH_PROFILE
|
||||
unset XAPIAN_PATH
|
||||
rm -f "$HOME/mail"
|
||||
cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
|
||||
}
|
||||
|
||||
|
@ -42,6 +43,18 @@ symlink_config () {
|
|||
unset DATABASE_PATH
|
||||
}
|
||||
|
||||
|
||||
home_mail_config () {
|
||||
local dir
|
||||
backup_config
|
||||
dir="${HOME}/mail"
|
||||
ln -s $MAIL_DIR $dir
|
||||
notmuch config set database.path
|
||||
notmuch config set database.mail_root
|
||||
XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
|
||||
unset DATABASE_PATH
|
||||
}
|
||||
|
||||
xdg_config () {
|
||||
local dir
|
||||
local profile=${1:-default}
|
||||
|
@ -66,7 +79,7 @@ xdg_config () {
|
|||
notmuch --config=${CONFIG_PATH} config set database.path
|
||||
}
|
||||
|
||||
for config in traditional split XDG XDG+profile symlink; do
|
||||
for config in traditional split XDG XDG+profile symlink home_mail; do
|
||||
#start each set of tests with an known set of messages
|
||||
add_email_corpus
|
||||
|
||||
|
@ -90,6 +103,9 @@ for config in traditional split XDG XDG+profile symlink; do
|
|||
symlink)
|
||||
symlink_config
|
||||
;;
|
||||
home_mail)
|
||||
home_mail_config
|
||||
;;
|
||||
esac
|
||||
|
||||
test_begin_subtest "count ($config)"
|
||||
|
@ -236,7 +252,9 @@ EOF
|
|||
test_begin_subtest "Config list ($config)"
|
||||
notmuch config list | notmuch_dir_sanitize | sed -e "s/^database.backup_dir=.*$/database.backup_dir/" \
|
||||
-e "s/^database.hook_dir=.*$/database.hook_dir/" \
|
||||
-e "s/^database.path=.*$/database.path/" > OUTPUT
|
||||
-e "s/^database.path=.*$/database.path/" \
|
||||
-e "s,^database.mail_root=CWD/home/mail,database.mail_root=MAIL_DIR," \
|
||||
> OUTPUT
|
||||
cat <<EOF > EXPECTED
|
||||
built_with.compact=true
|
||||
built_with.field_processor=true
|
||||
|
|
|
@ -22,7 +22,7 @@ EOF
|
|||
cat <<'EOF' >EXPECTED
|
||||
== stdout ==
|
||||
== stderr ==
|
||||
Error: Cannot open database at CWD/home/.local/share/notmuch/default: No such file or directory.
|
||||
Error: could not locate database.
|
||||
EOF
|
||||
test_expect_equal_file EXPECTED OUTPUT
|
||||
|
||||
|
@ -93,7 +93,7 @@ EOF
|
|||
cat <<'EOF' >EXPECTED
|
||||
== stdout ==
|
||||
== stderr ==
|
||||
Error: Cannot open database at CWD/home/.local/share/notmuch/default: No such file or directory.
|
||||
Error: could not locate database.
|
||||
EOF
|
||||
test_expect_equal_file EXPECTED OUTPUT
|
||||
|
||||
|
|
|
@ -546,8 +546,8 @@ cat <<'EOF' >EXPECTED
|
|||
== stdout ==
|
||||
== stderr ==
|
||||
error opening database
|
||||
Something went wrong trying to read or write a file
|
||||
Error: Cannot open database at CWD/home/.local/share/notmuch/default: No such file or directory.
|
||||
No database found
|
||||
Error: could not locate database.
|
||||
|
||||
EOF
|
||||
test_expect_equal_file EXPECTED OUTPUT
|
||||
|
|
Loading…
Reference in a new issue