Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion deepwell/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion deepwell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ intl-memoizer = "0.5"
jsonrpsee = { version = "0.24", features = ["macros", "server"] }
log = "0.4"
notify = { version = "8", optional = true }
once_cell = "1"
paste = "1"
rand = "0.8"
redis = { version = "0.28", features = ["aio", "connection-manager", "keep-alive", "tokio-comp", "tokio-rustls-comp"] }
Expand Down
21 changes: 11 additions & 10 deletions deepwell/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod build {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

use once_cell::sync::Lazy;
use std::sync::LazyLock;
use time::format_description::well_known::Rfc2822;
use time::OffsetDateTime;

Expand All @@ -33,12 +33,12 @@ pub use self::build::{
RUSTC_VERSION, TARGET,
};

pub static BUILT_TIME_UTC: Lazy<OffsetDateTime> = Lazy::new(|| {
pub static BUILT_TIME_UTC: LazyLock<OffsetDateTime> = LazyLock::new(|| {
OffsetDateTime::parse(BUILT_TIME_UTC_STR, &Rfc2822)
.expect("Unable to parse built time string")
});

pub static VERSION_INFO: Lazy<String> = Lazy::new(|| {
pub static VERSION_INFO: LazyLock<String> = LazyLock::new(|| {
let mut version = format!("v{PKG_VERSION}");

if let Some(commit_hash) = *GIT_COMMIT_HASH_SHORT {
Expand All @@ -48,7 +48,7 @@ pub static VERSION_INFO: Lazy<String> = Lazy::new(|| {
version
});

pub static COMPILE_INFO: Lazy<String> = Lazy::new(|| {
pub static COMPILE_INFO: LazyLock<String> = LazyLock::new(|| {
let mut info = str!("Compile info:\n");
str_writeln!(&mut info, "* on {BUILT_TIME_UTC_STR}");
str_writeln!(&mut info, "* by {RUSTC_VERSION}");
Expand All @@ -57,15 +57,16 @@ pub static COMPILE_INFO: Lazy<String> = Lazy::new(|| {
info
});

pub static VERSION: Lazy<String> = Lazy::new(|| format!("{PKG_NAME} {}", *VERSION_INFO));
pub static VERSION: LazyLock<String> =
LazyLock::new(|| format!("{PKG_NAME} {}", *VERSION_INFO));

pub static FULL_VERSION: Lazy<String> =
Lazy::new(|| format!("{}\n\n{}", *VERSION, *COMPILE_INFO));
pub static FULL_VERSION: LazyLock<String> =
LazyLock::new(|| format!("{}\n\n{}", *VERSION, *COMPILE_INFO));

pub static GIT_COMMIT_HASH_SHORT: Lazy<Option<&'static str>> =
Lazy::new(|| build::GIT_COMMIT_HASH.map(|s| &s[..8]));
pub static GIT_COMMIT_HASH_SHORT: LazyLock<Option<&'static str>> =
LazyLock::new(|| build::GIT_COMMIT_HASH.map(|s| &s[..8]));

pub static HOSTNAME: Lazy<String> = Lazy::new(|| {
pub static HOSTNAME: LazyLock<String> = LazyLock::new(|| {
// According to the gethostname(3p) man page,
// there don't seem to be any errors possible.
//
Expand Down
2 changes: 1 addition & 1 deletion deepwell/src/services/blob/mime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! Evaluates MIME types using libmagic.
//!
//! Because it is a binding to a C library, it cannot be shared among threads.
//! So we cannot use `once_cell::Lazy` and we can't have it in a coroutine.
//! So we cannot use `LazyLock` and we can't have it in a coroutine.
//! We don't load the `Magic` instance locally because it's an expensive operation
//! and it would be inefficient to load it for each invocation.
//!
Expand Down
6 changes: 3 additions & 3 deletions deepwell/src/services/file/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ use crate::services::filter::{FilterClass, FilterType};
use crate::services::{BlobService, FileRevisionService, FilterService, PageService};
use crate::types::FileOrder;
use crate::utils::regex_replace_in_place;
use once_cell::sync::Lazy;
use regex::Regex;
use sea_orm::ActiveValue;
use std::sync::LazyLock;

pub const MAXIMUM_FILE_NAME_LENGTH: usize = 256;

static LEADING_TRAILING_SPACES: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(^\s+)|(\s+$)").unwrap());
static LEADING_TRAILING_SPACES: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"(^\s+)|(\s+$)").unwrap());

#[derive(Debug)]
pub struct FileService;
Expand Down
6 changes: 3 additions & 3 deletions deepwell/src/services/file_revision/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ use crate::models::{file, page, site};
use crate::services::blob::{FinalizeBlobUploadOutput, EMPTY_BLOB_HASH, EMPTY_BLOB_MIME};
use crate::services::{BlobService, OutdateService, PageService};
use crate::types::{Bytes, FetchDirection};
use once_cell::sync::Lazy;
use sea_orm::{prelude::*, FromQueryResult};
use std::num::NonZeroI32;
use std::sync::LazyLock;

/// The changes for the first revision.
/// The first revision is always considered to have changed everything.
///
/// See `services/page_revision/service.rs`.
static ALL_CHANGES: Lazy<Vec<String>> =
Lazy::new(|| vec![str!("page"), str!("name"), str!("blob"), str!("mime")]);
static ALL_CHANGES: LazyLock<Vec<String>> =
LazyLock::new(|| vec![str!("page"), str!("name"), str!("blob"), str!("mime")]);

#[derive(Debug)]
pub struct FileRevisionService;
Expand Down
4 changes: 2 additions & 2 deletions deepwell/src/services/page_revision/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ use crate::utils::{split_category, split_category_name};
use ftml::data::PageInfo;
use ftml::layout::Layout;
use ftml::settings::{WikitextMode, WikitextSettings};
use once_cell::sync::Lazy;
use ref_map::*;
use std::num::NonZeroI32;
use std::sync::LazyLock;

/// The changes for the first revision.
/// The first revision is always considered to have changed everything.
///
/// See `services/file_revision/service.rs`.
static ALL_CHANGES: Lazy<Vec<String>> = Lazy::new(|| {
static ALL_CHANGES: LazyLock<Vec<String>> = LazyLock::new(|| {
vec![
str!("wikitext"),
str!("title"),
Expand Down
6 changes: 3 additions & 3 deletions deepwell/src/services/user/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ use crate::services::email::{EmailClassification, EmailService};
use crate::services::filter::{FilterClass, FilterType};
use crate::services::{AliasService, FilterService, PasswordService};
use crate::utils::regex_replace_in_place;
use once_cell::sync::Lazy;
use regex::Regex;
use sea_orm::ActiveValue;
use std::cmp;
use std::sync::LazyLock;

static LEADING_TRAILING_CHARS: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(^[\-\s]+)|([\-\s+]$)").unwrap());
static LEADING_TRAILING_CHARS: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"(^[\-\s]+)|([\-\s+]$)").unwrap());

#[derive(Debug)]
pub struct UserService;
Expand Down
Loading