mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
refactor: turn DC_VERSION_STR into &str
This commit is contained in:
@@ -43,7 +43,7 @@ async fn main_impl() -> Result<()> {
|
|||||||
if let Some(arg) = args.next() {
|
if let Some(arg) = args.next() {
|
||||||
return Err(anyhow!("Unrecognized argument {arg:?}"));
|
return Err(anyhow!("Unrecognized argument {arg:?}"));
|
||||||
}
|
}
|
||||||
eprintln!("{}", &*DC_VERSION_STR);
|
eprintln!("{DC_VERSION_STR}");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
} else if first_arg.to_str() == Some("--openrpc") {
|
} else if first_arg.to_str() == Some("--openrpc") {
|
||||||
if let Some(arg) = args.next() {
|
if let Some(arg) = args.next() {
|
||||||
|
|||||||
@@ -504,7 +504,7 @@ impl Context {
|
|||||||
.into_owned()
|
.into_owned()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Config::SysVersion => Some((*constants::DC_VERSION_STR).clone()),
|
Config::SysVersion => Some(constants::DC_VERSION_STR.to_string()),
|
||||||
Config::SysMsgsizeMaxRecommended => Some(format!("{RECOMMENDED_FILE_SIZE}")),
|
Config::SysMsgsizeMaxRecommended => Some(format!("{RECOMMENDED_FILE_SIZE}")),
|
||||||
Config::SysConfigKeys => Some(get_config_keys_string()),
|
Config::SysConfigKeys => Some(get_config_keys_string()),
|
||||||
_ => self.sql.get_raw_config(key.as_ref()).await?,
|
_ => self.sql.get_raw_config(key.as_ref()).await?,
|
||||||
|
|||||||
@@ -2,16 +2,13 @@
|
|||||||
|
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
use std::sync::LazyLock;
|
|
||||||
|
|
||||||
use deltachat_derive::{FromSql, ToSql};
|
use deltachat_derive::{FromSql, ToSql};
|
||||||
use percent_encoding::{AsciiSet, NON_ALPHANUMERIC};
|
use percent_encoding::{AsciiSet, NON_ALPHANUMERIC};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::chat::ChatId;
|
use crate::chat::ChatId;
|
||||||
|
|
||||||
pub static DC_VERSION_STR: LazyLock<String> =
|
pub static DC_VERSION_STR: &str = env!("CARGO_PKG_VERSION");
|
||||||
LazyLock::new(|| env!("CARGO_PKG_VERSION").to_string());
|
|
||||||
|
|
||||||
/// Set of characters to percent-encode in email addresses and names.
|
/// Set of characters to percent-encode in email addresses and names.
|
||||||
pub(crate) const NON_ALPHANUMERIC_WITHOUT_DOT: &AsciiSet = &NON_ALPHANUMERIC.remove(b'.');
|
pub(crate) const NON_ALPHANUMERIC_WITHOUT_DOT: &AsciiSet = &NON_ALPHANUMERIC.remove(b'.');
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ pub fn get_info() -> BTreeMap<&'static str, String> {
|
|||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
res.insert("debug_assertions", "Off".to_string());
|
res.insert("debug_assertions", "Off".to_string());
|
||||||
|
|
||||||
res.insert("deltachat_core_version", format!("v{}", &*DC_VERSION_STR));
|
res.insert("deltachat_core_version", format!("v{DC_VERSION_STR}"));
|
||||||
res.insert("sqlite_version", rusqlite::version().to_string());
|
res.insert("sqlite_version", rusqlite::version().to_string());
|
||||||
res.insert("arch", (std::mem::size_of::<usize>() * 8).to_string());
|
res.insert("arch", (std::mem::size_of::<usize>() * 8).to_string());
|
||||||
res.insert("num_cpus", num_cpus::get().to_string());
|
res.insert("num_cpus", num_cpus::get().to_string());
|
||||||
@@ -1334,10 +1334,5 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns core version as a string.
|
|
||||||
pub fn get_version_str() -> &'static str {
|
|
||||||
&DC_VERSION_STR
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod context_tests;
|
mod context_tests;
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ use serde::Serialize;
|
|||||||
|
|
||||||
use crate::chat::{self, ChatId, MuteDuration};
|
use crate::chat::{self, ChatId, MuteDuration};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::Chattype;
|
use crate::constants::{Chattype, DC_VERSION_STR};
|
||||||
use crate::contact::{Contact, ContactId, Origin, import_vcard, mark_contact_id_as_verified};
|
use crate::contact::{Contact, ContactId, Origin, import_vcard, mark_contact_id_as_verified};
|
||||||
use crate::context::{Context, get_version_str};
|
use crate::context::Context;
|
||||||
use crate::key::load_self_public_keyring;
|
use crate::key::load_self_public_keyring;
|
||||||
use crate::log::LogExt;
|
use crate::log::LogExt;
|
||||||
use crate::message::{Message, Viewtype};
|
use crate::message::{Message, Viewtype};
|
||||||
@@ -356,7 +356,7 @@ async fn get_stats(context: &Context) -> Result<String> {
|
|||||||
get_timestamps(context, "stats_sending_disabled_events").await?;
|
get_timestamps(context, "stats_sending_disabled_events").await?;
|
||||||
|
|
||||||
let stats = Statistics {
|
let stats = Statistics {
|
||||||
core_version: get_version_str().to_string(),
|
core_version: DC_VERSION_STR.to_string(),
|
||||||
key_create_timestamps,
|
key_create_timestamps,
|
||||||
stats_id: stats_id(context).await?,
|
stats_id: stats_id(context).await?,
|
||||||
is_chatmail: context.is_chatmail().await?,
|
is_chatmail: context.is_chatmail().await?,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ async fn test_maybe_send_stats() -> Result<()> {
|
|||||||
r.get("contact_stats").unwrap(),
|
r.get("contact_stats").unwrap(),
|
||||||
&serde_json::Value::Array(vec![])
|
&serde_json::Value::Array(vec![])
|
||||||
);
|
);
|
||||||
assert_eq!(r.get("core_version").unwrap(), get_version_str());
|
assert_eq!(r.get("core_version").unwrap(), DC_VERSION_STR);
|
||||||
|
|
||||||
assert_eq!(maybe_send_stats(alice).await?, None);
|
assert_eq!(maybe_send_stats(alice).await?, None);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user