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
}
}
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) {
unset DATABASE_PATH
unset NOTMUCH_PROFILE
unset XAPIAN_PATH
+ rm -f "$HOME/mail"
cp notmuch-config-backup.${test_name} ${NOTMUCH_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}
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
symlink)
symlink_config
;;
+ home_mail)
+ home_mail_config
+ ;;
esac
test_begin_subtest "count ($config)"
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
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
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
== 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