Browse Source

conf: Rename cache_type to search_backend

tags/v1
Manos Pitsidianakis 1 year ago
parent
commit
5ef62a39b8
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 6
      meli.1
  2. 4
      meli.conf.5
  3. 6
      src/components/mail/status.rs
  4. 30
      src/conf.rs
  5. 2
      src/conf/accounts.rs

6
meli.1

@ -143,7 +143,7 @@ uses the SEARCH command,
uses libnotmuch and
.Em Maildir/mbox
performs a slow linear search.
It is advised to use a cache on
It is advised to use a search backend on
.Em Maildir/mbox
accounts.
.Nm Ns
@ -159,7 +159,7 @@ and
.Em Date .
The message body (in plain text human readable form) and the flags can also be queried.
To enable sqlite3 indexing for an account set
.Em cache_type
.Em search_backend
to
.Em sqlite3
in the configuration file and to create the sqlite3 index issue command
@ -190,7 +190,7 @@ Quotes should always be escaped.
.Sy Important Notice about IMAP/JMAP
.sp
To prevent downloading all your messages from your IMAP/JMAP server, don't set
.Em cache_type
.Em search_backend
to
.Em sqlite3 Ns
\&.

4
meli.conf.5

@ -164,9 +164,9 @@ If true, do not monitor account for changes (you can use shortcut listing.refres
.Pq Em optional
command to execute when manually refreshing (shortcut listing.refresh)
.Pq Em None
.It Ic cache_type Ar String
.It Ic search_backend Ar String
.Pq Em optional
Choose which cache backend to use.
Choose which search backend to use.
Available options are 'none' and 'sqlite3'
.Pq Em "sqlite3"
.It Ic vcard_folder Ar String

6
src/components/mail/status.rs

@ -460,17 +460,17 @@ impl Component for AccountStatus {
);
write_string_to_grid(
&if a.settings.account().format() == "imap"
&& *a.settings.conf.cache_type() == CacheType::None
&& *a.settings.conf.search_backend() == SearchBackend::None
{
"server-side search".to_string()
} else if a.settings.account().format() == "notmuch"
&& *a.settings.conf.cache_type() == CacheType::None
&& *a.settings.conf.search_backend() == SearchBackend::None
{
"notmuch database".to_string()
} else {
#[cfg(feature = "sqlite3")]
{
if *a.settings.conf.cache_type() == CacheType::Sqlite3 {
if *a.settings.conf.search_backend() == SearchBackend::Sqlite3 {
if let Ok(path) = crate::sqlite3::db_path() {
format!("sqlite3 database {}", path.display())
} else {

30
src/conf.rs

@ -164,7 +164,7 @@ pub struct FileAccount {
#[serde(default)]
mailboxes: HashMap<String, FileMailboxConf>,
#[serde(default)]
cache_type: CacheType,
search_backend: SearchBackend,
#[serde(default = "false_val")]
pub manual_refresh: bool,
#[serde(default = "none")]
@ -220,8 +220,8 @@ impl FileAccount {
&self.root_mailbox
}
pub fn cache_type(&self) -> &CacheType {
&self.cache_type
pub fn search_backend(&self) -> &SearchBackend {
&self.search_backend
}
}
@ -417,7 +417,7 @@ impl FileSettings {
extra,
manual_refresh,
refresh_command: _,
cache_type: _,
search_backend: _,
conf_override: _,
} = acc.clone();
@ -630,26 +630,26 @@ impl Serialize for IndexStyle {
}
#[derive(Debug, Clone, PartialEq)]
pub enum CacheType {
pub enum SearchBackend {
None,
#[cfg(feature = "sqlite3")]
Sqlite3,
}
impl Default for CacheType {
impl Default for SearchBackend {
fn default() -> Self {
#[cfg(feature = "sqlite3")]
{
CacheType::Sqlite3
SearchBackend::Sqlite3
}
#[cfg(not(feature = "sqlite3"))]
{
CacheType::None
SearchBackend::None
}
}
}
impl<'de> Deserialize<'de> for CacheType {
impl<'de> Deserialize<'de> for SearchBackend {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: Deserializer<'de>,
@ -657,22 +657,22 @@ impl<'de> Deserialize<'de> for CacheType {
let s = <String>::deserialize(deserializer)?;
match s.as_str() {
#[cfg(feature = "sqlite3")]
"sqlite3" => Ok(CacheType::Sqlite3),
"nothing" | "none" | "" => Ok(CacheType::None),
_ => Err(de::Error::custom("invalid `index_cache` value")),
"sqlite3" => Ok(SearchBackend::Sqlite3),
"nothing" | "none" | "" => Ok(SearchBackend::None),
_ => Err(de::Error::custom("invalid `search_backend` value")),
}
}
}
impl Serialize for CacheType {
impl Serialize for SearchBackend {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
match self {
#[cfg(feature = "sqlite3")]
CacheType::Sqlite3 => serializer.serialize_str("sqlite3"),
CacheType::None => serializer.serialize_str("none"),
SearchBackend::Sqlite3 => serializer.serialize_str("sqlite3"),
SearchBackend::None => serializer.serialize_str("none"),
}
}
}

2
src/conf/accounts.rs

@ -353,7 +353,7 @@ impl Account {
};
if settings.account().format() == "imap" {
settings.conf.cache_type = crate::conf::CacheType::None;
settings.conf.search_backend = crate::conf::SearchBackend::None;
}
let mut active_jobs = HashMap::default();

Loading…
Cancel
Save