From e0773b9a6442547d9660c48aa0e6b382f9b8dcdc Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 19 Aug 2025 17:19:07 +0800 Subject: [PATCH] cargo clippy happy --- Cargo.lock | 179 +++++++++++++++++++------------------ src/controller/db_utils.rs | 8 +- src/controller/feed.rs | 94 +++++++++---------- src/controller/inn.rs | 54 ++++++----- src/controller/solo.rs | 42 +++++---- src/controller/tantivy.rs | 20 ++--- src/controller/user.rs | 22 ++--- typos.toml | 2 +- 8 files changed, 213 insertions(+), 208 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 36c251f..8e25ff8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.88" +version = "0.1.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", @@ -335,9 +335,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "6a65b545ab31d687cff52899d4890855fec459eb6afe0da6417b8a18da87aa29" [[package]] name = "bitpacking" @@ -359,9 +359,9 @@ dependencies = [ [[package]] name = "bon" -version = "3.6.5" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d9ef19ae5263a138da9a86871eca537478ab0332a7770bac7e3f08b801f89f" +checksum = "67a0c21249ad725ebcadcb1b1885f8e3d56e8e6b8924f560268aab000982d637" dependencies = [ "bon-macros", "rustversion", @@ -369,11 +369,11 @@ dependencies = [ [[package]] name = "bon-macros" -version = "3.6.5" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "577ae008f2ca11ca7641bd44601002ee5ab49ef0af64846ce1ab6057218a5cc1" +checksum = "a660ebdea4d4d3ec7788cfc9c035b66efb66028b9b97bf6cde7023ccc8e77e28" dependencies = [ - "darling 0.21.0", + "darling 0.21.2", "ident_case", "prettyplease", "proc-macro2", @@ -390,9 +390,9 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "bytemuck" -version = "1.23.1" +version = "1.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" +checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677" [[package]] name = "byteorder" @@ -421,9 +421,9 @@ dependencies = [ "ahash 0.8.12", "cached_proc_macro", "cached_proc_macro_types", - "hashbrown 0.15.4", + "hashbrown 0.15.5", "once_cell", - "thiserror 2.0.14", + "thiserror 2.0.15", "web-time", ] @@ -459,9 +459,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.30" +version = "1.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" +checksum = "3ee0f8803222ba5a7e2777dd72ca451868909b1ac410621b676adf07280e9b5f" dependencies = [ "jobserver", "libc", @@ -622,12 +622,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a79c4acb1fd5fa3d9304be4c76e031c54d2e92d172a393e24b19a14fe8532fe9" +checksum = "08440b3dd222c3d0433e63e097463969485f112baff337dfdaca043a0d760570" dependencies = [ - "darling_core 0.21.0", - "darling_macro 0.21.0", + "darling_core 0.21.2", + "darling_macro 0.21.2", ] [[package]] @@ -646,9 +646,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74875de90daf30eb59609910b84d4d368103aaec4c924824c6799b28f77d6a1d" +checksum = "d25b7912bc28a04ab1b7715a68ea03aaa15662b43a1a4b2c480531fd19f8bf7e" dependencies = [ "fnv", "ident_case", @@ -671,11 +671,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79f8e61677d5df9167cd85265f8e5f64b215cdea3fb55eebc3e622e44c7a146" +checksum = "ce154b9bea7fb0c8e8326e62d00354000c36e79770ff21b8c84e3aa267d9d531" dependencies = [ - "darling_core 0.21.0", + "darling_core 0.21.2", "quote", "syn", ] @@ -903,7 +903,7 @@ dependencies = [ "stop-words", "syntect", "tantivy", - "thiserror 2.0.14", + "thiserror 2.0.15", "tikv-jemallocator", "tokio", "tower", @@ -1061,9 +1061,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "h2" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785" +checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" dependencies = [ "atomic-waker", "bytes", @@ -1099,9 +1099,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.4" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ "allocator-api2", "equivalent", @@ -1203,13 +1203,14 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" dependencies = [ + "atomic-waker", "bytes", "futures-channel", - "futures-util", + "futures-core", "h2", "http", "http-body", @@ -1217,6 +1218,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", + "pin-utils", "smallvec", "tokio", "want", @@ -1469,7 +1471,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" dependencies = [ "equivalent", - "hashbrown 0.15.4", + "hashbrown 0.15.5", ] [[package]] @@ -1487,7 +1489,7 @@ version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", "cfg-if", "libc", ] @@ -1610,9 +1612,9 @@ checksum = "0c2cdeb66e45e9f36bfad5bbdb4d2384e70936afbee843c6f6543f0c551ebb25" [[package]] name = "libc" -version = "0.2.174" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "libflate" @@ -1705,7 +1707,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.4", + "hashbrown 0.15.5", ] [[package]] @@ -2007,7 +2009,7 @@ checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.15", + "redox_syscall 0.5.17", "smallvec", "windows-targets 0.52.6", ] @@ -2187,9 +2189,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "prettyplease" -version = "0.2.36" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", "syn", @@ -2219,9 +2221,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] @@ -2232,7 +2234,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e8bbe1a966bd2f362681a44f6edce3c2310ac21e4d5067a6e7ec396297a6ea0" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", "memchr", "pulldown-cmark-escape", "unicase", @@ -2268,7 +2270,7 @@ dependencies = [ "rustc-hash", "rustls", "socket2 0.5.10", - "thiserror 2.0.14", + "thiserror 2.0.15", "tokio", "tracing", "web-time", @@ -2289,7 +2291,7 @@ dependencies = [ "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.14", + "thiserror 2.0.15", "tinyvec", "tracing", "web-time", @@ -2395,9 +2397,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" dependencies = [ "either", "rayon-core", @@ -2405,9 +2407,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -2424,11 +2426,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.15" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8af0dde094006011e6a740d4879319439489813bd0bcdc7d821beaeeff48ec" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", ] [[package]] @@ -2563,9 +2565,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" [[package]] name = "rustc-hash" @@ -2579,7 +2581,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", "errno", "libc", "linux-raw-sys 0.4.15", @@ -2592,7 +2594,7 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", "errno", "libc", "linux-raw-sys 0.9.4", @@ -2601,9 +2603,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.29" +version = "0.23.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1" +checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" dependencies = [ "once_cell", "ring", @@ -2636,9 +2638,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" @@ -2683,9 +2685,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.141" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" +checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" dependencies = [ "itoa", "memchr", @@ -2880,9 +2882,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.104" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -2975,7 +2977,7 @@ dependencies = [ "tantivy-stacker", "tantivy-tokenizer-api", "tempfile", - "thiserror 2.0.14", + "thiserror 2.0.15", "time", "uuid", "winapi", @@ -3110,11 +3112,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.14" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0949c3a6c842cbde3f1686d6eea5a010516deb7085f79db747562d4102f41e" +checksum = "80d76d3f064b981389ecb4b6b7f45a0bf9fdac1d5b9204c7bd6714fecc302850" dependencies = [ - "thiserror-impl 2.0.14", + "thiserror-impl 2.0.15", ] [[package]] @@ -3130,9 +3132,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.14" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc5b44b4ab9c2fdd0e0512e6bece8388e214c0749f5862b114cc5b7a25daf227" +checksum = "44d29feb33e986b6ea906bd9c3559a856983f92371b3eaa5e83782a351623de0" dependencies = [ "proc-macro2", "quote", @@ -3211,9 +3213,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" dependencies = [ "tinyvec_macros", ] @@ -3265,9 +3267,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" dependencies = [ "bytes", "futures-core", @@ -3298,7 +3300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" dependencies = [ "async-compression", - "bitflags 2.9.1", + "bitflags 2.9.2", "bytes", "futures-core", "futures-util", @@ -3445,9 +3447,9 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "uuid" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" +checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be" dependencies = [ "getrandom 0.3.3", "js-sys", @@ -3686,6 +3688,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + [[package]] name = "windows-sys" version = "0.52.0" @@ -3710,7 +3718,7 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.2", + "windows-targets 0.53.3", ] [[package]] @@ -3731,10 +3739,11 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.2" +version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" dependencies = [ + "windows-link", "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", "windows_i686_gnu 0.53.0", @@ -3856,7 +3865,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.9.2", ] [[package]] @@ -3949,9 +3958,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.2" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" dependencies = [ "yoke", "zerofrom", @@ -4011,9 +4020,9 @@ checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" [[package]] name = "zune-jpeg" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9e525af0a6a658e031e95f14b7f889976b74a11ba0eca5a5fc9ac8a1c43a6a" +checksum = "fc1f7e205ce79eb2da3cd71c5f55f3589785cb7c79f6a03d1c8d1491bda5d089" dependencies = [ "zune-core", ] diff --git a/src/controller/db_utils.rs b/src/controller/db_utils.rs index d09012a..761aa9a 100644 --- a/src/controller/db_utils.rs +++ b/src/controller/db_utils.rs @@ -17,10 +17,10 @@ pub async fn clear_invalid(db: &Db, tree_name: &str) -> Result<(), AppError> { let time_stamp = k_str .split_once('_') .and_then(|s| i64::from_str_radix(s.0, 16).ok()); - if let Some(time_stamp) = time_stamp { - if time_stamp < Timestamp::now().as_second() { - tree.remove(k)?; - } + if let Some(time_stamp) = time_stamp + && time_stamp < Timestamp::now().as_second() + { + tree.remove(k)?; } } Ok(()) diff --git a/src/controller/feed.rs b/src/controller/feed.rs index 3c90465..aea8260 100644 --- a/src/controller/feed.rs +++ b/src/controller/feed.rs @@ -125,12 +125,11 @@ impl From for SourceItem { for extv in ext.values() { for m in extv { let c = m.children(); - if let Some(description) = c.get("description") { - if let Some(fd) = description.first() { - if let Some(d) = fd.value() { - desc = d.to_owned(); - } - } + if let Some(description) = c.get("description") + && let Some(fd) = description.first() + && let Some(d) = fd.value() + { + desc = d.to_owned(); } } } @@ -262,19 +261,20 @@ pub(crate) async fn feed( let out_feed = OutFeed::new(&DB, feed.feed_id, feed.is_public)?; e.push(out_feed); - if let Some(ref active_folder) = active_folder { - if active_folder != &feed.folder && !active_folder.is_empty() { - continue; - } + if let Some(ref active_folder) = active_folder + && active_folder != &feed.folder + && !active_folder.is_empty() + { + continue; } - if let Some(active_feed) = params.active_feed { - if active_feed != 0 { - if active_feed != feed.feed_id { - continue; - } - active_folder = Some(feed.folder) + if let Some(active_feed) = params.active_feed + && active_feed != 0 + { + if active_feed != feed.feed_id { + continue; } + active_folder = Some(feed.folder) } feed_ids.push(feed.feed_id); @@ -786,38 +786,38 @@ pub async fn cron_download_audio(db: &Db) -> Result<(), AppError> { let (k, _) = i?; let item_id = u8_slice_to_u32(&k); let mut item: Item = get_one(db, "items", item_id)?; - if let Some(ref podcast) = item.podcast { - if !podcast.audio_downloaded && !podcast.enclosure_url.is_empty() { - if !podcast.enclosure_length.is_empty() { - if let Ok(size) = podcast.enclosure_length.parse::() { - if size > MAX_FILE_SIZE { - warn!("Skipping item {item_id}: file too large ({size} bytes)"); - continue; - } - } + if let Some(ref podcast) = item.podcast + && !podcast.audio_downloaded + && !podcast.enclosure_url.is_empty() + { + if !podcast.enclosure_length.is_empty() + && let Ok(size) = podcast.enclosure_length.parse::() + && size > MAX_FILE_SIZE + { + warn!("Skipping item {item_id}: file too large ({size} bytes)"); + continue; + } + match CLIENT.get(&podcast.enclosure_url).send().await { + Ok(audio) if audio.status().is_success() => { + let audio_bytes = audio.bytes().await?; + let path = std::path::PathBuf::from(&CONFIG.podcast_path); + let filename = format!("{item_id}.mp3"); + let audio_path = path.join(&filename); + + std::fs::write(&audio_path, &audio_bytes)?; + item.podcast.as_mut().unwrap().audio_downloaded = true; + + set_one(db, "items", item_id, &item)?; + info!("downloaded audio for item {item_id}, saved to {audio_path:?}"); } - match CLIENT.get(&podcast.enclosure_url).send().await { - Ok(audio) if audio.status().is_success() => { - let audio_bytes = audio.bytes().await?; - let path = std::path::PathBuf::from(&CONFIG.podcast_path); - let filename = format!("{item_id}.mp3"); - let audio_path = path.join(&filename); - - std::fs::write(&audio_path, &audio_bytes)?; - item.podcast.as_mut().unwrap().audio_downloaded = true; - - set_one(db, "items", item_id, &item)?; - info!("downloaded audio for item {item_id}, saved to {audio_path:?}"); - } - Err(e) => { - warn!("failed to download audio for item {item_id}, error: {e}"); - } - Ok(resp) => { - warn!( - "failed to download audio for item {item_id}, status: {}", - resp.status() - ); - } + Err(e) => { + warn!("failed to download audio for item {item_id}, error: {e}"); + } + Ok(resp) => { + warn!( + "failed to download audio for item {item_id}, status: {}", + resp.status() + ); } } } diff --git a/src/controller/inn.rs b/src/controller/inn.rs index 4ed728a..55ed63f 100644 --- a/src/controller/inn.rs +++ b/src/controller/inn.rs @@ -414,10 +414,10 @@ pub(crate) async fn inn_list( if let Some(topic) = ¶ms.topic { for i in get_ids_by_tag(&DB, "topics", topic, Some(&page_params))? { - if let Ok(inn) = get_one::(&DB, "inns", i) { - if !inn.is_closed() { - inns.push(inn); - } + if let Ok(inn) = get_one::(&DB, "inns", i) + && !inn.is_closed() + { + inns.push(inn); } } } else if let Some(claim) = &claim { @@ -430,10 +430,10 @@ pub(crate) async fn inn_list( } } else if params.filter.as_deref() == Some("joined") { for i in get_ids_by_prefix(&DB, "user_inns", uid_ivec, Some(&page_params))? { - if let Ok(inn) = get_one::(&DB, "inns", i) { - if !inn.is_closed() { - inns.push(inn); - } + if let Ok(inn) = get_one::(&DB, "inns", i) + && !inn.is_closed() + { + inns.push(inn); } } } else { @@ -525,10 +525,10 @@ pub(crate) async fn edit_post( let inn: Inn = get_one(&DB, "inns", id)?; if !inn.is_closed() { let inn_role = InnRole::get(&DB, inn.iid, claim.uid)?; - if let Some(role) = inn_role { - if role >= InnRole::Intern { - joined.push((inn.inn_name, inn.iid)); - } + if let Some(role) = inn_role + && role >= InnRole::Intern + { + joined.push((inn.inn_name, inn.iid)); } } } @@ -997,12 +997,11 @@ pub(crate) async fn inn( let out_post_list = get_out_post_list(&DB, &index)?; let mut inn_role = 0; - if let Some(ref claim) = claim { - if iid > 0 { - if let Ok(Some(role)) = InnRole::get(&DB, iid, claim.uid) { - inn_role = role as u8; - } - } + if let Some(ref claim) = claim + && iid > 0 + && let Ok(Some(role)) = InnRole::get(&DB, iid, claim.uid) + { + inn_role = role as u8; } let inn_users_count = if iid > 0 { @@ -1829,16 +1828,15 @@ pub(crate) async fn comment_post( let reply_to = extract_element(&content, 5, '#'); let mut reply_to_cid = None; - if !reply_to.is_empty() { - if let Ok(reply_cid) = reply_to[0].parse::() { - if reply_cid < cid { - let reply_link = format!("[{}](/post/{}/{}#{})", reply_to[0], iid, pid, reply_cid); - let from = format!("#{reply_cid}"); - let to = format!("#{reply_link}"); - content = content.replace(&from, &to); - reply_to_cid = Some(reply_cid); - } - } + if !reply_to.is_empty() + && let Ok(reply_cid) = reply_to[0].parse::() + && reply_cid < cid + { + let reply_link = format!("[{}](/post/{}/{}#{})", reply_to[0], iid, pid, reply_cid); + let from = format!("#{reply_cid}"); + let to = format!("#{reply_link}"); + content = content.replace(&from, &to); + reply_to_cid = Some(reply_cid); } let comment = Comment { diff --git a/src/controller/solo.rs b/src/controller/solo.rs index 9e992f4..f30b065 100644 --- a/src/controller/solo.rs +++ b/src/controller/solo.rs @@ -184,25 +184,23 @@ pub(crate) async fn solo_list( match params.filter.as_deref() { Some("Following") => { - if let Some(ref claim) = claim { - if let Ok(uids) = + if let Some(ref claim) = claim + && let Ok(uids) = get_ids_by_prefix(&DB, "user_following", u32_to_ivec(claim.uid), None) - { - index = get_solos_by_uids(&DB, &uids, &followers, current_uid, &page_params)?; - }; + { + index = get_solos_by_uids(&DB, &uids, &followers, current_uid, &page_params)?; } } Some("Like") => { - if let Some(ref claim) = claim { - if let Ok(sids) = + if let Some(ref claim) = claim + && let Ok(sids) = get_ids_by_prefix(&DB, "user_solos_like", u32_to_ivec(claim.uid), None) - { - let (start, end) = get_range(sids.len(), &page_params); - index = sids[start - 1..end].to_vec(); - if is_desc { - index.reverse(); - } - }; + { + let (start, end) = get_range(sids.len(), &page_params); + index = sids[start - 1..end].to_vec(); + if is_desc { + index.reverse(); + } } } _ => { @@ -285,14 +283,14 @@ pub(crate) async fn solo( } } - if let Some(nid) = params.nid { - if let Some(ref claim) = claim { - let prefix = [&u32_to_ivec(claim.uid), &u32_to_ivec(nid)].concat(); - let tree = DB.open_tree("notifications")?; - for i in tree.scan_prefix(prefix) { - let (k, _) = i?; - tree.update_and_fetch(k, mark_read)?; - } + if let Some(nid) = params.nid + && let Some(ref claim) = claim + { + let prefix = [&u32_to_ivec(claim.uid), &u32_to_ivec(nid)].concat(); + let tree = DB.open_tree("notifications")?; + for i in tree.scan_prefix(prefix) { + let (k, _) = i?; + tree.update_and_fetch(k, mark_read)?; } } diff --git a/src/controller/tantivy.rs b/src/controller/tantivy.rs index de01ddb..8f577fc 100644 --- a/src/controller/tantivy.rs +++ b/src/controller/tantivy.rs @@ -77,17 +77,17 @@ pub(crate) async fn search( let search = input.search.trim(); let mut query = search.to_owned(); - if let Some(ref uid) = input.uid { - if !uid.is_empty() { - query.push_str(" uid:"); - query.push_str(uid); - }; + if let Some(ref uid) = input.uid + && !uid.is_empty() + { + query.push_str(" uid:"); + query.push_str(uid); } - if let Some(ref ctype) = input.ctype { - if ctype != "all" { - query.push_str(" ctype:"); - query.push_str(ctype); - } + if let Some(ref ctype) = input.ctype + && ctype != "all" + { + query.push_str(" ctype:"); + query.push_str(ctype); }; let mut ids = IndexSet::with_capacity(20); diff --git a/src/controller/user.rs b/src/controller/user.rs index 4fe46e8..38188d8 100644 --- a/src/controller/user.rs +++ b/src/controller/user.rs @@ -705,14 +705,14 @@ pub(crate) async fn reset_post( }; let mut user: User = get_one(&DB, "users", uid)?; - if let Some(ref recovery_hash) = user.recovery_hash { - if check_password(&input.recovery_code, recovery_hash) { - user.password_hash = generate_password_hash(&input.password); - set_one(&DB, "users", uid, &user)?; + if let Some(ref recovery_hash) = user.recovery_hash + && check_password(&input.recovery_code, recovery_hash) + { + user.password_hash = generate_password_hash(&input.password); + set_one(&DB, "users", uid, &user)?; - return Ok(Redirect::to("/signin").into_response()); - }; - } + return Ok(Redirect::to("/signin").into_response()); + }; Err(AppError::NotFound) } @@ -749,10 +749,10 @@ pub(crate) async fn user_setting_post( let username_key = username.replace(' ', "_").to_lowercase(); let username_tree = DB.open_tree("usernames")?; - if let Some(v) = username_tree.get(&username_key)? { - if ivec_to_u32(&v) != claim.uid { - return Err(AppError::NameExists); - } + if let Some(v) = username_tree.get(&username_key)? + && ivec_to_u32(&v) != claim.uid + { + return Err(AppError::NameExists); } if user.username != username { diff --git a/typos.toml b/typos.toml index 13d7900..3430c49 100644 --- a/typos.toml +++ b/typos.toml @@ -1,2 +1,2 @@ [files] -extend-exclude = ["i18n/*.toml","static/js/*.js"] +extend-exclude = ["i18n/*.toml","static/js/*.min.js"]