Replace 3rd party once_cell crate with recently stabilized standard library API (#4919)

* Replace 3rd party once_cell crate with recently stabilized standard library API

* Bump CI rust version
This commit is contained in:
SleeplessOne1917 2024-07-30 14:11:39 +00:00 committed by GitHub
parent 069a9509d5
commit 1ef375e5c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 145 additions and 150 deletions

View file

@ -2,7 +2,7 @@
# See https://github.com/woodpecker-ci/woodpecker/issues/1677 # See https://github.com/woodpecker-ci/woodpecker/issues/1677
variables: variables:
- &rust_image "rust:1.78" - &rust_image "rust:1.80"
- &rust_nightly_image "rustlang/rust:nightly" - &rust_nightly_image "rustlang/rust:nightly"
- &install_pnpm "corepack enable pnpm" - &install_pnpm "corepack enable pnpm"
- &slow_check_paths - &slow_check_paths

164
Cargo.lock generated
View file

@ -219,7 +219,7 @@ dependencies = [
"actix-utils", "actix-utils",
"futures-core", "futures-core",
"futures-util", "futures-util",
"mio", "mio 0.8.11",
"socket2", "socket2",
"tokio", "tokio",
"tracing", "tracing",
@ -423,9 +423,9 @@ dependencies = [
[[package]] [[package]]
name = "anstream" name = "anstream"
version = "0.6.14" version = "0.6.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"anstyle-parse", "anstyle-parse",
@ -438,33 +438,33 @@ dependencies = [
[[package]] [[package]]
name = "anstyle" name = "anstyle"
version = "1.0.7" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
[[package]] [[package]]
name = "anstyle-parse" name = "anstyle-parse"
version = "0.2.4" version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
dependencies = [ dependencies = [
"utf8parse", "utf8parse",
] ]
[[package]] [[package]]
name = "anstyle-query" name = "anstyle-query"
version = "1.1.0" version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
dependencies = [ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
name = "anstyle-wincon" name = "anstyle-wincon"
version = "3.0.3" version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"windows-sys 0.52.0", "windows-sys 0.52.0",
@ -970,9 +970,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.9" version = "4.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -980,9 +980,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.5.9" version = "4.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -992,9 +992,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.5.8" version = "4.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e"
dependencies = [ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2", "proc-macro2",
@ -1004,9 +1004,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
[[package]] [[package]]
name = "clokwerk" name = "clokwerk"
@ -1061,9 +1061,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]] [[package]]
name = "colorchoice" name = "colorchoice"
version = "1.0.1" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
[[package]] [[package]]
name = "combine" name = "combine"
@ -1096,7 +1096,7 @@ dependencies = [
"ron", "ron",
"serde", "serde",
"serde_json", "serde_json",
"toml 0.8.15", "toml 0.8.16",
"yaml-rust", "yaml-rust",
] ]
@ -2435,7 +2435,7 @@ dependencies = [
"http 1.1.0", "http 1.1.0",
"hyper 1.4.1", "hyper 1.4.1",
"hyper-util", "hyper-util",
"rustls 0.23.11", "rustls 0.23.12",
"rustls-pki-types", "rustls-pki-types",
"tokio", "tokio",
"tokio-rustls 0.26.0", "tokio-rustls 0.26.0",
@ -2630,9 +2630,9 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
[[package]] [[package]]
name = "is_terminal_polyfill" name = "is_terminal_polyfill"
version = "1.70.0" version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]] [[package]]
name = "itertools" name = "itertools"
@ -2689,9 +2689,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]] [[package]]
name = "jobserver" name = "jobserver"
version = "0.1.31" version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -2790,7 +2790,6 @@ dependencies = [
"lemmy_utils", "lemmy_utils",
"mime", "mime",
"moka", "moka",
"once_cell",
"pretty_assertions", "pretty_assertions",
"regex", "regex",
"reqwest 0.11.27", "reqwest 0.11.27",
@ -2824,7 +2823,6 @@ dependencies = [
"lemmy_db_views_actor", "lemmy_db_views_actor",
"lemmy_utils", "lemmy_utils",
"moka", "moka",
"once_cell",
"tracing", "tracing",
"url", "url",
"uuid", "uuid",
@ -2854,7 +2852,6 @@ dependencies = [
"lemmy_db_views_actor", "lemmy_db_views_actor",
"lemmy_utils", "lemmy_utils",
"moka", "moka",
"once_cell",
"pretty_assertions", "pretty_assertions",
"reqwest 0.11.27", "reqwest 0.11.27",
"serde", "serde",
@ -2905,10 +2902,9 @@ dependencies = [
"i-love-jesus", "i-love-jesus",
"lemmy_utils", "lemmy_utils",
"moka", "moka",
"once_cell",
"pretty_assertions", "pretty_assertions",
"regex", "regex",
"rustls 0.23.11", "rustls 0.23.12",
"serde", "serde",
"serde_json", "serde_json",
"serde_with", "serde_with",
@ -2997,7 +2993,6 @@ dependencies = [
"lemmy_utils", "lemmy_utils",
"mockall", "mockall",
"moka", "moka",
"once_cell",
"reqwest 0.11.27", "reqwest 0.11.27",
"serde_json", "serde_json",
"serial_test", "serial_test",
@ -3024,7 +3019,6 @@ dependencies = [
"lemmy_db_views", "lemmy_db_views",
"lemmy_db_views_actor", "lemmy_db_views_actor",
"lemmy_utils", "lemmy_utils",
"once_cell",
"reqwest 0.11.27", "reqwest 0.11.27",
"reqwest-middleware 0.2.5", "reqwest-middleware 0.2.5",
"rss", "rss",
@ -3066,7 +3060,7 @@ dependencies = [
"reqwest 0.11.27", "reqwest 0.11.27",
"reqwest-middleware 0.2.5", "reqwest-middleware 0.2.5",
"reqwest-tracing 0.4.8", "reqwest-tracing 0.4.8",
"rustls 0.23.11", "rustls 0.23.12",
"serde_json", "serde_json",
"serial_test", "serial_test",
"tokio", "tokio",
@ -3096,7 +3090,6 @@ dependencies = [
"itertools 0.13.0", "itertools 0.13.0",
"lettre", "lettre",
"markdown-it", "markdown-it",
"once_cell",
"pretty_assertions", "pretty_assertions",
"regex", "regex",
"reqwest 0.11.27", "reqwest 0.11.27",
@ -3136,7 +3129,7 @@ dependencies = [
"nom", "nom",
"percent-encoding", "percent-encoding",
"quoted_printable", "quoted_printable",
"rustls 0.23.11", "rustls 0.23.12",
"rustls-pemfile 2.1.2", "rustls-pemfile 2.1.2",
"socket2", "socket2",
"tokio", "tokio",
@ -3473,6 +3466,18 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "mio"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4"
dependencies = [
"hermit-abi",
"libc",
"wasi",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "mirai-annotations" name = "mirai-annotations"
version = "1.12.0" version = "1.12.0"
@ -4108,7 +4113,7 @@ dependencies = [
"reqwest 0.12.5", "reqwest 0.12.5",
"reqwest-middleware 0.3.2", "reqwest-middleware 0.3.2",
"reqwest-tracing 0.5.2", "reqwest-tracing 0.5.2",
"rustls 0.23.11", "rustls 0.23.12",
"rustls-channel-resolver", "rustls-channel-resolver",
"rustls-pemfile 2.1.2", "rustls-pemfile 2.1.2",
"rusty-s3", "rusty-s3",
@ -4126,7 +4131,7 @@ dependencies = [
"tokio-postgres", "tokio-postgres",
"tokio-postgres-generic-rustls", "tokio-postgres-generic-rustls",
"tokio-util", "tokio-util",
"toml 0.8.15", "toml 0.8.16",
"tracing", "tracing",
"tracing-actix-web", "tracing-actix-web",
"tracing-error", "tracing-error",
@ -4305,9 +4310,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
[[package]] [[package]]
name = "predicates" name = "predicates"
version = "3.1.0" version = "3.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"predicates-core", "predicates-core",
@ -4315,15 +4320,15 @@ dependencies = [
[[package]] [[package]]
name = "predicates-core" name = "predicates-core"
version = "1.0.6" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931"
[[package]] [[package]]
name = "predicates-tree" name = "predicates-tree"
version = "1.0.9" version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13"
dependencies = [ dependencies = [
"predicates-core", "predicates-core",
"termtree", "termtree",
@ -4523,7 +4528,7 @@ dependencies = [
"quinn-proto", "quinn-proto",
"quinn-udp", "quinn-udp",
"rustc-hash", "rustc-hash",
"rustls 0.23.11", "rustls 0.23.12",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing", "tracing",
@ -4539,7 +4544,7 @@ dependencies = [
"rand", "rand",
"ring", "ring",
"rustc-hash", "rustc-hash",
"rustls 0.23.11", "rustls 0.23.12",
"slab", "slab",
"thiserror", "thiserror",
"tinyvec", "tinyvec",
@ -4548,9 +4553,9 @@ dependencies = [
[[package]] [[package]]
name = "quinn-udp" name = "quinn-udp"
version = "0.5.3" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25a78e6f726d84fcf960409f509ae354a32648f090c8d32a2ea8b1a1bc3bab14" checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285"
dependencies = [ dependencies = [
"libc", "libc",
"once_cell", "once_cell",
@ -4677,7 +4682,7 @@ dependencies = [
"time", "time",
"tokio", "tokio",
"tokio-postgres", "tokio-postgres",
"toml 0.8.15", "toml 0.8.16",
"url", "url",
"walkdir", "walkdir",
] ]
@ -4818,7 +4823,7 @@ dependencies = [
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"quinn", "quinn",
"rustls 0.23.11", "rustls 0.23.12",
"rustls-pemfile 2.1.2", "rustls-pemfile 2.1.2",
"rustls-pki-types", "rustls-pki-types",
"serde", "serde",
@ -5044,9 +5049,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.23.11" version = "0.23.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044"
dependencies = [ dependencies = [
"aws-lc-rs", "aws-lc-rs",
"log", "log",
@ -5065,7 +5070,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fede2a247359da6b4998f7723ec6468c2d6a577a5d8c17e54f21806426ad2290" checksum = "fede2a247359da6b4998f7723ec6468c2d6a577a5d8c17e54f21806426ad2290"
dependencies = [ dependencies = [
"nanorand", "nanorand",
"rustls 0.23.11", "rustls 0.23.12",
] ]
[[package]] [[package]]
@ -5157,9 +5162,9 @@ dependencies = [
[[package]] [[package]]
name = "scc" name = "scc"
version = "2.1.4" version = "2.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4465c22496331e20eb047ff46e7366455bc01c0c02015c4a376de0b2cd3a1af" checksum = "1fadf67e3cf23f8b11a6c8c48a16cb2437381503615acd91094ec7b4686a5a53"
dependencies = [ dependencies = [
"sdd", "sdd",
] ]
@ -5297,9 +5302,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
version = "0.6.6" version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -5909,22 +5914,21 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.38.1" version = "1.39.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
"libc", "libc",
"mio", "mio 1.0.1",
"num_cpus",
"parking_lot 0.12.3", "parking_lot 0.12.3",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
"socket2", "socket2",
"tokio-macros", "tokio-macros",
"tracing", "tracing",
"windows-sys 0.48.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@ -5939,9 +5943,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "2.3.0" version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -5991,7 +5995,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8e98c31c29b2666fb28720739e11476166be4ead1610a37dcd7414bb124413a" checksum = "c8e98c31c29b2666fb28720739e11476166be4ead1610a37dcd7414bb124413a"
dependencies = [ dependencies = [
"aws-lc-rs", "aws-lc-rs",
"rustls 0.23.11", "rustls 0.23.12",
"tokio", "tokio",
"tokio-postgres", "tokio-postgres",
"tokio-rustls 0.26.0", "tokio-rustls 0.26.0",
@ -6005,7 +6009,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04fb792ccd6bbcd4bba408eb8a292f70fc4a3589e5d793626f45190e6454b6ab" checksum = "04fb792ccd6bbcd4bba408eb8a292f70fc4a3589e5d793626f45190e6454b6ab"
dependencies = [ dependencies = [
"ring", "ring",
"rustls 0.23.11", "rustls 0.23.12",
"tokio", "tokio",
"tokio-postgres", "tokio-postgres",
"tokio-rustls 0.26.0", "tokio-rustls 0.26.0",
@ -6028,7 +6032,7 @@ version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4"
dependencies = [ dependencies = [
"rustls 0.23.11", "rustls 0.23.12",
"rustls-pki-types", "rustls-pki-types",
"tokio", "tokio",
] ]
@ -6071,21 +6075,21 @@ dependencies = [
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.8.15" version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c"
dependencies = [ dependencies = [
"serde", "serde",
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
"toml_edit 0.22.16", "toml_edit 0.22.17",
] ]
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.6.6" version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -6105,15 +6109,15 @@ dependencies = [
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.22.16" version = "0.22.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16"
dependencies = [ dependencies = [
"indexmap 2.2.6", "indexmap 2.2.6",
"serde", "serde",
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
"winnow 0.6.14", "winnow 0.6.16",
] ]
[[package]] [[package]]
@ -6204,9 +6208,9 @@ dependencies = [
[[package]] [[package]]
name = "totp-rs" name = "totp-rs"
version = "5.5.1" version = "5.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c4ae9724c5888c0417d2396037ed3b60665925624766416e3e342b6ba5dbd3f" checksum = "17b2f27dad992486c26b4e7455f38aa487e838d6d61b57e72906ee2b8c287a90"
dependencies = [ dependencies = [
"base32", "base32",
"constant_time_eq", "constant_time_eq",
@ -7015,9 +7019,9 @@ dependencies = [
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.6.14" version = "0.6.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "374ec40a2d767a3c1b4972d9475ecd557356637be906f2cb3f7fe17a6eb5e22f" checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]

View file

@ -146,7 +146,6 @@ typed-builder = "0.18.2"
serial_test = "3.1.1" serial_test = "3.1.1"
tokio = { version = "1.38.0", features = ["full"] } tokio = { version = "1.38.0", features = ["full"] }
regex = "1.10.4" regex = "1.10.4"
once_cell = "1.19.0"
diesel-derive-newtype = "2.1.2" diesel-derive-newtype = "2.1.2"
diesel-derive-enum = { version = "2.1.0", features = ["postgres"] } diesel-derive-enum = { version = "2.1.0", features = ["postgres"] }
strum = { version = "0.26.3", features = ["derive"] } strum = { version = "0.26.3", features = ["derive"] }

View file

@ -34,7 +34,6 @@ full = [
"reqwest", "reqwest",
"actix-web", "actix-web",
"futures", "futures",
"once_cell",
"jsonwebtoken", "jsonwebtoken",
"mime", "mime",
] ]
@ -61,7 +60,6 @@ reqwest = { workspace = true, optional = true }
ts-rs = { workspace = true, optional = true } ts-rs = { workspace = true, optional = true }
moka.workspace = true moka.workspace = true
anyhow.workspace = true anyhow.workspace = true
once_cell = { workspace = true, optional = true }
actix-web = { workspace = true, optional = true } actix-web = { workspace = true, optional = true }
enum-map = { workspace = true } enum-map = { workspace = true }
urlencoding = { workspace = true } urlencoding = { workspace = true }

View file

@ -13,7 +13,7 @@ use lemmy_db_schema::{
}; };
use lemmy_db_views::structs::PrivateMessageView; use lemmy_db_views::structs::PrivateMessageView;
use lemmy_utils::error::LemmyResult; use lemmy_utils::error::LemmyResult;
use once_cell::sync::{Lazy, OnceCell}; use std::sync::{LazyLock, OnceLock};
use tokio::{ use tokio::{
sync::{ sync::{
mpsc, mpsc,
@ -28,7 +28,7 @@ type MatchOutgoingActivitiesBoxed =
Box<for<'a> fn(SendActivityData, &'a Data<LemmyContext>) -> BoxFuture<'a, LemmyResult<()>>>; Box<for<'a> fn(SendActivityData, &'a Data<LemmyContext>) -> BoxFuture<'a, LemmyResult<()>>>;
/// This static is necessary so that the api_common crates don't need to depend on lemmy_apub /// This static is necessary so that the api_common crates don't need to depend on lemmy_apub
pub static MATCH_OUTGOING_ACTIVITIES: OnceCell<MatchOutgoingActivitiesBoxed> = OnceCell::new(); pub static MATCH_OUTGOING_ACTIVITIES: OnceLock<MatchOutgoingActivitiesBoxed> = OnceLock::new();
#[derive(Debug)] #[derive(Debug)]
pub enum SendActivityData { pub enum SendActivityData {
@ -101,7 +101,7 @@ pub enum SendActivityData {
// TODO: instead of static, move this into LemmyContext. make sure that stopping the process with // TODO: instead of static, move this into LemmyContext. make sure that stopping the process with
// ctrl+c still works. // ctrl+c still works.
static ACTIVITY_CHANNEL: Lazy<ActivityChannel> = Lazy::new(|| { static ACTIVITY_CHANNEL: LazyLock<ActivityChannel> = LazyLock::new(|| {
let (sender, receiver) = mpsc::unbounded_channel(); let (sender, receiver) = mpsc::unbounded_channel();
let weak_sender = sender.downgrade(); let weak_sender = sender.downgrade();
ActivityChannel { ActivityChannel {

View file

@ -53,10 +53,9 @@ use lemmy_utils::{
CACHE_DURATION_FEDERATION, CACHE_DURATION_FEDERATION,
}; };
use moka::future::Cache; use moka::future::Cache;
use once_cell::sync::Lazy;
use regex::{escape, Regex, RegexSet}; use regex::{escape, Regex, RegexSet};
use rosetta_i18n::{Language, LanguageId}; use rosetta_i18n::{Language, LanguageId};
use std::collections::HashSet; use std::{collections::HashSet, sync::LazyLock};
use tracing::warn; use tracing::warn;
use url::{ParseError, Url}; use url::{ParseError, Url};
use urlencoding::encode; use urlencoding::encode;
@ -546,7 +545,7 @@ pub fn local_site_opt_to_sensitive(local_site: &Option<LocalSite>) -> bool {
} }
pub async fn get_url_blocklist(context: &LemmyContext) -> LemmyResult<RegexSet> { pub async fn get_url_blocklist(context: &LemmyContext) -> LemmyResult<RegexSet> {
static URL_BLOCKLIST: Lazy<Cache<(), RegexSet>> = Lazy::new(|| { static URL_BLOCKLIST: LazyLock<Cache<(), RegexSet>> = LazyLock::new(|| {
Cache::builder() Cache::builder()
.max_capacity(1) .max_capacity(1)
.time_to_live(CACHE_DURATION_FEDERATION) .time_to_live(CACHE_DURATION_FEDERATION)

View file

@ -26,7 +26,6 @@ url = { workspace = true }
futures.workspace = true futures.workspace = true
uuid = { workspace = true } uuid = { workspace = true }
moka.workspace = true moka.workspace = true
once_cell.workspace = true
anyhow.workspace = true anyhow.workspace = true
webmention = "0.5.0" webmention = "0.5.0"
accept-language = "3.1.0" accept-language = "3.1.0"

View file

@ -24,14 +24,14 @@ use lemmy_utils::{
VERSION, VERSION,
}; };
use moka::future::Cache; use moka::future::Cache;
use once_cell::sync::Lazy; use std::sync::LazyLock;
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
pub async fn get_site( pub async fn get_site(
local_user_view: Option<LocalUserView>, local_user_view: Option<LocalUserView>,
context: Data<LemmyContext>, context: Data<LemmyContext>,
) -> LemmyResult<Json<GetSiteResponse>> { ) -> LemmyResult<Json<GetSiteResponse>> {
static CACHE: Lazy<Cache<(), GetSiteResponse>> = Lazy::new(|| { static CACHE: LazyLock<Cache<(), GetSiteResponse>> = LazyLock::new(|| {
Cache::builder() Cache::builder()
.max_capacity(1) .max_capacity(1)
.time_to_live(CACHE_DURATION_API) .time_to_live(CACHE_DURATION_API)

View file

@ -40,7 +40,6 @@ uuid = { workspace = true }
async-trait = { workspace = true } async-trait = { workspace = true }
anyhow = { workspace = true } anyhow = { workspace = true }
reqwest = { workspace = true } reqwest = { workspace = true }
once_cell = { workspace = true }
moka.workspace = true moka.workspace = true
serde_with.workspace = true serde_with.workspace = true
html2md = "0.2.14" html2md = "0.2.14"

View file

@ -14,9 +14,8 @@ use lemmy_utils::{
CACHE_DURATION_FEDERATION, CACHE_DURATION_FEDERATION,
}; };
use moka::future::Cache; use moka::future::Cache;
use once_cell::sync::Lazy;
use serde_json::Value; use serde_json::Value;
use std::sync::Arc; use std::sync::{Arc, LazyLock};
use url::Url; use url::Url;
pub mod activities; pub mod activities;
@ -36,7 +35,7 @@ pub const FEDERATION_HTTP_FETCH_LIMIT: u32 = 100;
/// Only include a basic context to save space and bandwidth. The main context is hosted statically /// Only include a basic context to save space and bandwidth. The main context is hosted statically
/// on join-lemmy.org. Include activitystreams explicitly for better compat, but this could /// on join-lemmy.org. Include activitystreams explicitly for better compat, but this could
/// theoretically also be moved. /// theoretically also be moved.
pub static FEDERATION_CONTEXT: Lazy<Value> = Lazy::new(|| { pub static FEDERATION_CONTEXT: LazyLock<Value> = LazyLock::new(|| {
Value::Array(vec![ Value::Array(vec![
Value::String("https://join-lemmy.org/context.json".to_string()), Value::String("https://join-lemmy.org/context.json".to_string()),
Value::String("https://www.w3.org/ns/activitystreams".to_string()), Value::String("https://www.w3.org/ns/activitystreams".to_string()),
@ -129,7 +128,7 @@ pub(crate) async fn local_site_data_cached(
// multiple times. This causes a huge number of database reads if we hit the db directly. So we // multiple times. This causes a huge number of database reads if we hit the db directly. So we
// cache these values for a short time, which will already make a huge difference and ensures that // cache these values for a short time, which will already make a huge difference and ensures that
// changes take effect quickly. // changes take effect quickly.
static CACHE: Lazy<Cache<(), Arc<LocalSiteData>>> = Lazy::new(|| { static CACHE: LazyLock<Cache<(), Arc<LocalSiteData>>> = LazyLock::new(|| {
Cache::builder() Cache::builder()
.max_capacity(1) .max_capacity(1)
.time_to_live(CACHE_DURATION_FEDERATION) .time_to_live(CACHE_DURATION_FEDERATION)

View file

@ -27,7 +27,6 @@ full = [
"lemmy_utils", "lemmy_utils",
"activitypub_federation", "activitypub_federation",
"regex", "regex",
"once_cell",
"serde_json", "serde_json",
"diesel_ltree", "diesel_ltree",
"diesel-async", "diesel-async",
@ -64,7 +63,6 @@ diesel-async = { workspace = true, features = [
"deadpool", "deadpool",
], optional = true } ], optional = true }
regex = { workspace = true, optional = true } regex = { workspace = true, optional = true }
once_cell = { workspace = true, optional = true }
diesel_ltree = { workspace = true, optional = true } diesel_ltree = { workspace = true, optional = true }
typed-builder = { workspace = true } typed-builder = { workspace = true }
async-trait = { workspace = true } async-trait = { workspace = true }

View file

@ -7,7 +7,7 @@ use diesel::{dsl::insert_into, result::Error};
use diesel_async::RunQueryDsl; use diesel_async::RunQueryDsl;
use lemmy_utils::{error::LemmyResult, CACHE_DURATION_API}; use lemmy_utils::{error::LemmyResult, CACHE_DURATION_API};
use moka::future::Cache; use moka::future::Cache;
use once_cell::sync::Lazy; use std::sync::LazyLock;
impl LocalSite { impl LocalSite {
pub async fn create(pool: &mut DbPool<'_>, form: &LocalSiteInsertForm) -> Result<Self, Error> { pub async fn create(pool: &mut DbPool<'_>, form: &LocalSiteInsertForm) -> Result<Self, Error> {
@ -18,7 +18,7 @@ impl LocalSite {
.await .await
} }
pub async fn read(pool: &mut DbPool<'_>) -> LemmyResult<Self> { pub async fn read(pool: &mut DbPool<'_>) -> LemmyResult<Self> {
static CACHE: Lazy<Cache<(), LocalSite>> = Lazy::new(|| { static CACHE: LazyLock<Cache<(), LocalSite>> = LazyLock::new(|| {
Cache::builder() Cache::builder()
.max_capacity(1) .max_capacity(1)
.time_to_live(CACHE_DURATION_API) .time_to_live(CACHE_DURATION_API)

View file

@ -32,7 +32,6 @@ use lemmy_utils::{
settings::SETTINGS, settings::SETTINGS,
utils::validation::clean_url_params, utils::validation::clean_url_params,
}; };
use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use rustls::{ use rustls::{
client::danger::{ client::danger::{
@ -49,7 +48,7 @@ use rustls::{
}; };
use std::{ use std::{
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
sync::Arc, sync::{Arc, LazyLock},
time::Duration, time::Duration,
}; };
use tracing::error; use tracing::error;
@ -478,7 +477,7 @@ pub fn post_to_comment_sort_type(sort: SortType) -> CommentSortType {
} }
} }
static EMAIL_REGEX: Lazy<Regex> = Lazy::new(|| { static EMAIL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$") Regex::new(r"^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$")
.expect("compile email regex") .expect("compile email regex")
}); });

View file

@ -27,7 +27,6 @@ futures.workspace = true
chrono.workspace = true chrono.workspace = true
diesel = { workspace = true, features = ["postgres", "chrono", "serde_json"] } diesel = { workspace = true, features = ["postgres", "chrono", "serde_json"] }
diesel-async = { workspace = true, features = ["deadpool", "postgres"] } diesel-async = { workspace = true, features = ["deadpool", "postgres"] }
once_cell.workspace = true
reqwest.workspace = true reqwest.workspace = true
serde_json.workspace = true serde_json.workspace = true
tokio = { workspace = true, features = ["full"] } tokio = { workspace = true, features = ["full"] }

View file

@ -8,9 +8,11 @@ use lemmy_db_schema::{
utils::{ActualDbPool, DbPool}, utils::{ActualDbPool, DbPool},
}; };
use lemmy_db_views_actor::structs::CommunityFollowerView; use lemmy_db_views_actor::structs::CommunityFollowerView;
use once_cell::sync::Lazy;
use reqwest::Url; use reqwest::Url;
use std::collections::{HashMap, HashSet}; use std::{
collections::{HashMap, HashSet},
sync::LazyLock,
};
/// interval with which new additions to community_followers are queried. /// interval with which new additions to community_followers are queried.
/// ///
@ -21,7 +23,7 @@ use std::collections::{HashMap, HashSet};
/// currently fairly high because of the current structure of storing inboxes for every person, not /// currently fairly high because of the current structure of storing inboxes for every person, not
/// having a separate list of shared_inboxes, and the architecture of having every instance queue be /// having a separate list of shared_inboxes, and the architecture of having every instance queue be
/// fully separate. (see https://github.com/LemmyNet/lemmy/issues/3958) /// fully separate. (see https://github.com/LemmyNet/lemmy/issues/3958)
static FOLLOW_ADDITIONS_RECHECK_DELAY: Lazy<chrono::TimeDelta> = Lazy::new(|| { static FOLLOW_ADDITIONS_RECHECK_DELAY: LazyLock<chrono::TimeDelta> = LazyLock::new(|| {
if *LEMMY_TEST_FAST_FEDERATION { if *LEMMY_TEST_FAST_FEDERATION {
chrono::TimeDelta::try_seconds(1).expect("TimeDelta out of bounds") chrono::TimeDelta::try_seconds(1).expect("TimeDelta out of bounds")
} else { } else {
@ -31,8 +33,8 @@ static FOLLOW_ADDITIONS_RECHECK_DELAY: Lazy<chrono::TimeDelta> = Lazy::new(|| {
/// The same as FOLLOW_ADDITIONS_RECHECK_DELAY, but triggering when the last person on an instance /// The same as FOLLOW_ADDITIONS_RECHECK_DELAY, but triggering when the last person on an instance
/// unfollows a specific remote community. This is expected to happen pretty rarely and updating it /// unfollows a specific remote community. This is expected to happen pretty rarely and updating it
/// in a timely manner is not too important. /// in a timely manner is not too important.
static FOLLOW_REMOVALS_RECHECK_DELAY: Lazy<chrono::TimeDelta> = static FOLLOW_REMOVALS_RECHECK_DELAY: LazyLock<chrono::TimeDelta> =
Lazy::new(|| chrono::TimeDelta::try_hours(1).expect("TimeDelta out of bounds")); LazyLock::new(|| chrono::TimeDelta::try_hours(1).expect("TimeDelta out of bounds"));
#[async_trait] #[async_trait]
pub trait DataSource: Send + Sync { pub trait DataSource: Send + Sync {

View file

@ -18,10 +18,15 @@ use lemmy_db_schema::{
utils::{get_conn, DbPool}, utils::{get_conn, DbPool},
}; };
use moka::future::Cache; use moka::future::Cache;
use once_cell::sync::Lazy;
use reqwest::Url; use reqwest::Url;
use serde_json::Value; use serde_json::Value;
use std::{fmt::Debug, future::Future, pin::Pin, sync::Arc, time::Duration}; use std::{
fmt::Debug,
future::Future,
pin::Pin,
sync::{Arc, LazyLock},
time::Duration,
};
use tokio::{task::JoinHandle, time::sleep}; use tokio::{task::JoinHandle, time::sleep};
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
@ -29,7 +34,7 @@ use tokio_util::sync::CancellationToken;
/// Should only be used for federation tests since it significantly increases CPU and DB load of the /// Should only be used for federation tests since it significantly increases CPU and DB load of the
/// federation queue. This is intentionally a separate flag from other flags like debug_assertions, /// federation queue. This is intentionally a separate flag from other flags like debug_assertions,
/// since this is a invasive change we only need rarely. /// since this is a invasive change we only need rarely.
pub(crate) static LEMMY_TEST_FAST_FEDERATION: Lazy<bool> = Lazy::new(|| { pub(crate) static LEMMY_TEST_FAST_FEDERATION: LazyLock<bool> = LazyLock::new(|| {
std::env::var("LEMMY_TEST_FAST_FEDERATION") std::env::var("LEMMY_TEST_FAST_FEDERATION")
.map(|s| !s.is_empty()) .map(|s| !s.is_empty())
.unwrap_or(false) .unwrap_or(false)
@ -49,7 +54,7 @@ pub(crate) static LEMMY_TEST_FAST_FEDERATION: Lazy<bool> = Lazy::new(|| {
/// If the delay is too short, the workers (one per federated instance) will wake up too /// If the delay is too short, the workers (one per federated instance) will wake up too
/// often and consume a lot of CPU. If the delay is long, then activities on low-traffic instances /// often and consume a lot of CPU. If the delay is long, then activities on low-traffic instances
/// will on average take delay/2 seconds to federate. /// will on average take delay/2 seconds to federate.
pub(crate) static WORK_FINISHED_RECHECK_DELAY: Lazy<Duration> = Lazy::new(|| { pub(crate) static WORK_FINISHED_RECHECK_DELAY: LazyLock<Duration> = LazyLock::new(|| {
if *LEMMY_TEST_FAST_FEDERATION { if *LEMMY_TEST_FAST_FEDERATION {
Duration::from_millis(100) Duration::from_millis(100)
} else { } else {
@ -61,7 +66,7 @@ pub(crate) static WORK_FINISHED_RECHECK_DELAY: Lazy<Duration> = Lazy::new(|| {
/// ///
/// This cache is common to all the instance workers and prevents there from being more than one /// This cache is common to all the instance workers and prevents there from being more than one
/// call per N seconds between each DB query to find max(activity_id). /// call per N seconds between each DB query to find max(activity_id).
pub(crate) static CACHE_DURATION_LATEST_ID: Lazy<Duration> = Lazy::new(|| { pub(crate) static CACHE_DURATION_LATEST_ID: LazyLock<Duration> = LazyLock::new(|| {
if *LEMMY_TEST_FAST_FEDERATION { if *LEMMY_TEST_FAST_FEDERATION {
// in test mode, we use the same cache duration as the recheck delay so when recheck happens // in test mode, we use the same cache duration as the recheck delay so when recheck happens
// data is fresh, accelerating the time the tests take. // data is fresh, accelerating the time the tests take.
@ -132,8 +137,8 @@ pub(crate) async fn get_actor_cached(
actor_type: ActorType, actor_type: ActorType,
actor_apub_id: &Url, actor_apub_id: &Url,
) -> Result<Arc<SiteOrCommunityOrUser>> { ) -> Result<Arc<SiteOrCommunityOrUser>> {
static CACHE: Lazy<Cache<Url, Arc<SiteOrCommunityOrUser>>> = static CACHE: LazyLock<Cache<Url, Arc<SiteOrCommunityOrUser>>> =
Lazy::new(|| Cache::builder().max_capacity(10000).build()); LazyLock::new(|| Cache::builder().max_capacity(10000).build());
CACHE CACHE
.try_get_with(actor_apub_id.clone(), async { .try_get_with(actor_apub_id.clone(), async {
let url = actor_apub_id.clone().into(); let url = actor_apub_id.clone().into();
@ -172,8 +177,8 @@ pub(crate) async fn get_activity_cached(
pool: &mut DbPool<'_>, pool: &mut DbPool<'_>,
activity_id: ActivityId, activity_id: ActivityId,
) -> Result<CachedActivityInfo> { ) -> Result<CachedActivityInfo> {
static ACTIVITIES: Lazy<Cache<ActivityId, CachedActivityInfo>> = static ACTIVITIES: LazyLock<Cache<ActivityId, CachedActivityInfo>> =
Lazy::new(|| Cache::builder().max_capacity(10000).build()); LazyLock::new(|| Cache::builder().max_capacity(10000).build());
ACTIVITIES ACTIVITIES
.try_get_with(activity_id, async { .try_get_with(activity_id, async {
let row = SentActivity::read(pool, activity_id) let row = SentActivity::read(pool, activity_id)
@ -195,7 +200,7 @@ pub(crate) async fn get_activity_cached(
/// return the most current activity id (with 1 second cache) /// return the most current activity id (with 1 second cache)
pub(crate) async fn get_latest_activity_id(pool: &mut DbPool<'_>) -> Result<ActivityId> { pub(crate) async fn get_latest_activity_id(pool: &mut DbPool<'_>) -> Result<ActivityId> {
static CACHE: Lazy<Cache<(), ActivityId>> = Lazy::new(|| { static CACHE: LazyLock<Cache<(), ActivityId>> = LazyLock::new(|| {
Cache::builder() Cache::builder()
.time_to_live(*CACHE_DURATION_LATEST_ID) .time_to_live(*CACHE_DURATION_LATEST_ID)
.build() .build()

View file

@ -30,7 +30,6 @@ reqwest = { workspace = true, features = ["stream"] }
reqwest-middleware = { workspace = true } reqwest-middleware = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
url = { workspace = true } url = { workspace = true }
once_cell = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
urlencoding = { workspace = true } urlencoding = { workspace = true }

View file

@ -25,7 +25,6 @@ use lemmy_utils::{
error::{LemmyError, LemmyErrorType, LemmyResult}, error::{LemmyError, LemmyErrorType, LemmyResult},
utils::markdown::{markdown_to_html, sanitize_html}, utils::markdown::{markdown_to_html, sanitize_html},
}; };
use once_cell::sync::Lazy;
use rss::{ use rss::{
extension::{dublincore::DublinCoreExtension, ExtensionBuilder, ExtensionMap}, extension::{dublincore::DublinCoreExtension, ExtensionBuilder, ExtensionMap},
Channel, Channel,
@ -34,7 +33,7 @@ use rss::{
Item, Item,
}; };
use serde::Deserialize; use serde::Deserialize;
use std::{collections::BTreeMap, str::FromStr}; use std::{collections::BTreeMap, str::FromStr, sync::LazyLock};
const RSS_FETCH_LIMIT: i64 = 20; const RSS_FETCH_LIMIT: i64 = 20;
@ -80,7 +79,7 @@ pub fn config(cfg: &mut web::ServiceConfig) {
); );
} }
static RSS_NAMESPACE: Lazy<BTreeMap<String, String>> = Lazy::new(|| { static RSS_NAMESPACE: LazyLock<BTreeMap<String, String>> = LazyLock::new(|| {
let mut h = BTreeMap::new(); let mut h = BTreeMap::new();
h.insert( h.insert(
"dc".to_string(), "dc".to_string(),

View file

@ -39,7 +39,6 @@ full = [
"dep:urlencoding", "dep:urlencoding",
"dep:doku", "dep:doku",
"dep:url", "dep:url",
"dep:once_cell",
"dep:smart-default", "dep:smart-default",
"dep:enum-map", "dep:enum-map",
"dep:futures", "dep:futures",
@ -58,7 +57,6 @@ tracing-error = { workspace = true, optional = true }
itertools = { workspace = true, optional = true } itertools = { workspace = true, optional = true }
serde = { workspace = true } serde = { workspace = true }
serde_json = { workspace = true, optional = true } serde_json = { workspace = true, optional = true }
once_cell = { workspace = true, optional = true }
url = { workspace = true, optional = true } url = { workspace = true, optional = true }
actix-web = { workspace = true, optional = true } actix-web = { workspace = true, optional = true }
anyhow = { workspace = true, optional = true } anyhow = { workspace = true, optional = true }

View file

@ -1,15 +1,15 @@
use enum_map::EnumMap; use enum_map::EnumMap;
use once_cell::sync::Lazy;
use std::{ use std::{
collections::HashMap, collections::HashMap,
hash::Hash, hash::Hash,
net::{IpAddr, Ipv4Addr, Ipv6Addr}, net::{IpAddr, Ipv4Addr, Ipv6Addr},
sync::LazyLock,
time::Instant, time::Instant,
}; };
use strum::{AsRefStr, Display}; use strum::{AsRefStr, Display};
use tracing::debug; use tracing::debug;
static START_TIME: Lazy<Instant> = Lazy::new(Instant::now); static START_TIME: LazyLock<Instant> = LazyLock::new(Instant::now);
/// Smaller than `std::time::Instant` because it uses a smaller integer for seconds and doesn't /// Smaller than `std::time::Instant` because it uses a smaller integer for seconds and doesn't
/// store nanoseconds /// store nanoseconds

View file

@ -1,9 +1,8 @@
use crate::{error::LemmyResult, location_info}; use crate::{error::LemmyResult, location_info};
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use deser_hjson::from_str; use deser_hjson::from_str;
use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use std::{env, fs, io::Error}; use std::{env, fs, io::Error, sync::LazyLock};
use urlencoding::encode; use urlencoding::encode;
pub mod structs; pub mod structs;
@ -12,7 +11,7 @@ use structs::{DatabaseConnection, PictrsConfig, PictrsImageMode, Settings};
static DEFAULT_CONFIG_FILE: &str = "config/config.hjson"; static DEFAULT_CONFIG_FILE: &str = "config/config.hjson";
pub static SETTINGS: Lazy<Settings> = Lazy::new(|| { pub static SETTINGS: LazyLock<Settings> = LazyLock::new(|| {
if env::var("LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS").is_ok() { if env::var("LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS").is_ok() {
println!( println!(
"LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS was set, any configuration file has been ignored." "LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS was set, any configuration file has been ignored."
@ -24,7 +23,7 @@ pub static SETTINGS: Lazy<Settings> = Lazy::new(|| {
} }
}); });
static WEBFINGER_REGEX: Lazy<Regex> = Lazy::new(|| { static WEBFINGER_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(&format!( Regex::new(&format!(
"^acct:([a-zA-Z0-9_]{{3,}})@{}$", "^acct:([a-zA-Z0-9_]{{3,}})@{}$",
SETTINGS.hostname SETTINGS.hostname

View file

@ -1,14 +1,14 @@
use crate::{error::LemmyResult, settings::SETTINGS, LemmyErrorType}; use crate::{error::LemmyResult, settings::SETTINGS, LemmyErrorType};
use markdown_it::{plugins::cmark::inline::image::Image, MarkdownIt}; use markdown_it::{plugins::cmark::inline::image::Image, MarkdownIt};
use once_cell::sync::Lazy;
use regex::RegexSet; use regex::RegexSet;
use std::sync::LazyLock;
use url::Url; use url::Url;
use urlencoding::encode; use urlencoding::encode;
mod link_rule; mod link_rule;
mod spoiler_rule; mod spoiler_rule;
static MARKDOWN_PARSER: Lazy<MarkdownIt> = Lazy::new(|| { static MARKDOWN_PARSER: LazyLock<MarkdownIt> = LazyLock::new(|| {
let mut parser = MarkdownIt::new(); let mut parser = MarkdownIt::new();
markdown_it::plugins::cmark::add(&mut parser); markdown_it::plugins::cmark::add(&mut parser);
markdown_it::plugins::extra::add(&mut parser); markdown_it::plugins::extra::add(&mut parser);

View file

@ -34,8 +34,8 @@ use markdown_it::{
NodeValue, NodeValue,
Renderer, Renderer,
}; };
use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use std::sync::LazyLock;
#[derive(Debug)] #[derive(Debug)]
struct SpoilerBlock { struct SpoilerBlock {
@ -46,8 +46,8 @@ const SPOILER_PREFIX: &str = "::: spoiler ";
const SPOILER_SUFFIX: &str = ":::"; const SPOILER_SUFFIX: &str = ":::";
const SPOILER_SUFFIX_NEWLINE: &str = ":::\n"; const SPOILER_SUFFIX_NEWLINE: &str = ":::\n";
static SPOILER_REGEX: Lazy<Regex> = static SPOILER_REGEX: LazyLock<Regex> =
Lazy::new(|| Regex::new(r"^::: spoiler .*$").expect("compile spoiler markdown regex.")); LazyLock::new(|| Regex::new(r"^::: spoiler .*$").expect("compile spoiler markdown regex."));
impl NodeValue for SpoilerBlock { impl NodeValue for SpoilerBlock {
// Formats any node marked as a 'SpoilerBlock' into HTML. // Formats any node marked as a 'SpoilerBlock' into HTML.

View file

@ -1,8 +1,8 @@
use itertools::Itertools; use itertools::Itertools;
use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use std::sync::LazyLock;
static MENTIONS_REGEX: Lazy<Regex> = Lazy::new(|| { static MENTIONS_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"@(?P<name>[\w.]+)@(?P<domain>[a-zA-Z0-9._:-]+)").expect("compile regex") Regex::new(r"@(?P<name>[\w.]+)@(?P<domain>[a-zA-Z0-9._:-]+)").expect("compile regex")
}); });
// TODO nothing is done with community / group webfingers yet, so just ignore those for now // TODO nothing is done with community / group webfingers yet, so just ignore those for now

View file

@ -1,16 +1,16 @@
use crate::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; use crate::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
use itertools::Itertools; use itertools::Itertools;
use once_cell::sync::Lazy;
use regex::{Regex, RegexBuilder, RegexSet}; use regex::{Regex, RegexBuilder, RegexSet};
use std::sync::LazyLock;
use url::{ParseError, Url}; use url::{ParseError, Url};
// From here: https://github.com/vector-im/element-android/blob/develop/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixPatterns.kt#L35 // From here: https://github.com/vector-im/element-android/blob/develop/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixPatterns.kt#L35
static VALID_MATRIX_ID_REGEX: Lazy<Regex> = Lazy::new(|| { static VALID_MATRIX_ID_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"^@[A-Za-z0-9\x21-\x39\x3B-\x7F]+:[A-Za-z0-9.-]+(:[0-9]{2,5})?$") Regex::new(r"^@[A-Za-z0-9\x21-\x39\x3B-\x7F]+:[A-Za-z0-9.-]+(:[0-9]{2,5})?$")
.expect("compile regex") .expect("compile regex")
}); });
// taken from https://en.wikipedia.org/wiki/UTM_parameters // taken from https://en.wikipedia.org/wiki/UTM_parameters
static CLEAN_URL_PARAMS_REGEX: Lazy<Regex> = Lazy::new(|| { static CLEAN_URL_PARAMS_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new( Regex::new(
r"^(utm_source|utm_medium|utm_campaign|utm_term|utm_content|gclid|gclsrc|dclid|fbclid)=", r"^(utm_source|utm_medium|utm_campaign|utm_term|utm_content|gclid|gclsrc|dclid|fbclid)=",
) )
@ -87,12 +87,12 @@ fn has_newline(name: &str) -> bool {
} }
pub fn is_valid_actor_name(name: &str, actor_name_max_length: usize) -> LemmyResult<()> { pub fn is_valid_actor_name(name: &str, actor_name_max_length: usize) -> LemmyResult<()> {
static VALID_ACTOR_NAME_REGEX_EN: Lazy<Regex> = static VALID_ACTOR_NAME_REGEX_EN: LazyLock<Regex> =
Lazy::new(|| Regex::new(r"^[a-zA-Z0-9_]{3,}$").expect("compile regex")); LazyLock::new(|| Regex::new(r"^[a-zA-Z0-9_]{3,}$").expect("compile regex"));
static VALID_ACTOR_NAME_REGEX_AR: Lazy<Regex> = static VALID_ACTOR_NAME_REGEX_AR: LazyLock<Regex> =
Lazy::new(|| Regex::new(r"^[\p{Arabic}0-9_]{3,}$").expect("compile regex")); LazyLock::new(|| Regex::new(r"^[\p{Arabic}0-9_]{3,}$").expect("compile regex"));
static VALID_ACTOR_NAME_REGEX_RU: Lazy<Regex> = static VALID_ACTOR_NAME_REGEX_RU: LazyLock<Regex> =
Lazy::new(|| Regex::new(r"^[\p{Cyrillic}0-9_]{3,}$").expect("compile regex")); LazyLock::new(|| Regex::new(r"^[\p{Cyrillic}0-9_]{3,}$").expect("compile regex"));
let check = name.chars().count() <= actor_name_max_length && !has_newline(name); let check = name.chars().count() <= actor_name_max_length && !has_newline(name);

View file

@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.8 # syntax=docker/dockerfile:1.8
ARG RUST_VERSION=1.78 ARG RUST_VERSION=1.80
ARG CARGO_BUILD_FEATURES=default ARG CARGO_BUILD_FEATURES=default
ARG RUST_RELEASE_MODE=debug ARG RUST_RELEASE_MODE=debug