From b7448e8366d842aff3720aa288d9274ef0a7076f Mon Sep 17 00:00:00 2001 From: Cameron Garnham Date: Fri, 13 Oct 2023 19:52:38 +0200 Subject: [PATCH] chore: update deps --- Cargo.lock | 365 ++++++++++++++++++++++++++++++---------- Cargo.toml | 80 ++++----- src/databases/mysql.rs | 33 ++-- src/databases/sqlite.rs | 33 ++-- 4 files changed, 344 insertions(+), 167 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4cc90f32..8f2e0653 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,6 +35,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", + "getrandom", "once_cell", "version_check", ] @@ -143,9 +144,9 @@ dependencies = [ [[package]] name = "atoi" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ "num-traits", ] @@ -256,6 +257,9 @@ name = "bitflags" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +dependencies = [ + "serde", +] [[package]] name = "blake2" @@ -380,9 +384,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.7.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "convert_case" @@ -458,16 +462,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crypto-bigint" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -489,13 +483,13 @@ dependencies = [ [[package]] name = "der" -version = "0.5.1" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", - "crypto-bigint", "pem-rfc7468", + "zeroize", ] [[package]] @@ -535,6 +529,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", "subtle", ] @@ -556,6 +551,9 @@ name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +dependencies = [ + "serde", +] [[package]] name = "email-encoding" @@ -601,6 +599,17 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -648,7 +657,7 @@ checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall", "windows-sys", ] @@ -676,13 +685,12 @@ checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" [[package]] name = "flume" -version = "0.10.14" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ "futures-core", "futures-sink", - "pin-project", "spin 0.9.8", ] @@ -771,9 +779,9 @@ dependencies = [ [[package]] name = "futures-intrusive" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", @@ -922,6 +930,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac", +] + [[package]] name = "hmac" version = "0.12.1" @@ -1249,9 +1266,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libsqlite3-sys" -version = "0.24.2" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" +checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" dependencies = [ "cc", "pkg-config", @@ -1304,6 +1321,16 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + [[package]] name = "memchr" version = "2.6.4" @@ -1548,27 +1575,25 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.6" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", - "instant", "libc", - "redox_syscall 0.2.16", + "redox_syscall", "smallvec", - "winapi", + "windows-targets", ] [[package]] @@ -1617,9 +1642,9 @@ dependencies = [ [[package]] name = "pem-rfc7468" -version = "0.3.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01de5d978f34aa4b2296576379fcc416034702fd94117c56ffd8a1a767cefb30" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" dependencies = [ "base64ct", ] @@ -1715,24 +1740,23 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkcs1" -version = "0.3.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78f66c04ccc83dd4486fd46c33896f4e17b24a7a3a6400dedc48ed0ddd72320" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" dependencies = [ "der", "pkcs8", - "zeroize", + "spki", ] [[package]] name = "pkcs8" -version = "0.8.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ "der", "spki", - "zeroize", ] [[package]] @@ -1820,15 +1844,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ae028b272a6e99d9f8260ceefa3caa09300a8d6c8d2b2001316474bc52122e9" -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.3.5" @@ -1967,11 +1982,12 @@ dependencies = [ [[package]] name = "rsa" -version = "0.6.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf22754c49613d2b3b119f0e5d46e34a2c628a937e3024b8762de4e7d8c710b" +checksum = "6ab43bb47d23c1a631b4b680199a45255dce26fa9ab2fa902581f624ff13e6a8" dependencies = [ "byteorder", + "const-oid", "digest", "num-bigint-dig", "num-integer", @@ -1980,7 +1996,8 @@ dependencies = [ "pkcs1", "pkcs8", "rand_core", - "smallvec", + "signature", + "spki", "subtle", "zeroize", ] @@ -2103,9 +2120,9 @@ dependencies = [ [[package]] name = "sailfish" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a48cead573ab494535cd9f24838a721a613e5da899ee974c8e2fdbb3d60222" +checksum = "7861181faa2e413410444757deca246c70959cee725fbfd8f736a94a660eb377" dependencies = [ "itoap", "ryu", @@ -2115,9 +2132,9 @@ dependencies = [ [[package]] name = "sailfish-compiler" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26deb100e96e303d266d1852525b1da033678ed9eabd539f5ed5eba01333394" +checksum = "7c38d77ced03b393e820ac70109857bd857f93e746f5d7d631829c9ee2e4f3fa" dependencies = [ "filetime", "home", @@ -2131,9 +2148,9 @@ dependencies = [ [[package]] name = "sailfish-macros" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41162f9a79f2541458a1cf20f8d81d55bb2bcbdd03d295c29765d9bcb43188c9" +checksum = "c8f73db14456f861a5c89166ab6ac76afd94b4d2a9416638ae2952ae051089c5" dependencies = [ "proc-macro2", "sailfish-compiler", @@ -2316,6 +2333,16 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest", + "rand_core", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -2401,9 +2428,9 @@ dependencies = [ [[package]] name = "spki" -version = "0.5.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", "der", @@ -2422,93 +2449,202 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.6.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8de3b03a925878ed54a954f621e64bf55a3c1bd29652d0d1a17830405350188" +checksum = "0e50c216e3624ec8e7ecd14c6a6a6370aad6ee5d8cfc3ab30b5162eeeef2ed33" dependencies = [ "sqlx-core", "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", ] [[package]] name = "sqlx-core" -version = "0.6.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" +checksum = "8d6753e460c998bbd4cd8c6f0ed9a64346fcca0723d6e75e52fdc351c5d2169d" dependencies = [ - "ahash 0.7.6", + "ahash 0.8.3", "atoi", - "bitflags 1.3.2", "byteorder", "bytes", "crc", "crossbeam-queue", - "digest", "dotenvy", "either", "event-listener", - "flume", "futures-channel", "futures-core", - "futures-executor", "futures-intrusive", + "futures-io", "futures-util", - "generic-array", "hashlink", "hex", - "indexmap 1.9.3", - "itoa", - "libc", - "libsqlite3-sys", + "indexmap 2.0.2", "log", "memchr", - "num-bigint", + "native-tls", "once_cell", "paste", "percent-encoding", - "rand", - "rsa", - "sha1", + "serde", + "serde_json", "sha2", "smallvec", "sqlformat", - "sqlx-rt", - "stringprep", "thiserror", "time", + "tokio", "tokio-stream", + "tracing", "url", ] [[package]] name = "sqlx-macros" -version = "0.6.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" +checksum = "9a793bb3ba331ec8359c1853bd39eed32cdd7baaf22c35ccf5c92a7e8d1189ec" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4ee1e104e00dedb6aa5ffdd1343107b0a4702e862a84320ee7cc74782d96fc" dependencies = [ "dotenvy", "either", "heck", + "hex", "once_cell", "proc-macro2", "quote", + "serde", + "serde_json", "sha2", "sqlx-core", - "sqlx-rt", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", "syn 1.0.109", + "tempfile", + "tokio", "url", ] [[package]] -name = "sqlx-rt" -version = "0.6.3" +name = "sqlx-mysql" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" +checksum = "864b869fdf56263f4c95c45483191ea0af340f9f3e3e7b4d57a61c7c87a970db" dependencies = [ - "native-tls", + "atoi", + "base64 0.21.4", + "bitflags 2.4.0", + "byteorder", + "bytes", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", "once_cell", - "tokio", - "tokio-native-tls", + "percent-encoding", + "rand", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb7ae0e6a97fb3ba33b23ac2671a5ce6e3cabe003f451abd5a56e7951d975624" +dependencies = [ + "atoi", + "base64 0.21.4", + "bitflags 2.4.0", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand", + "serde", + "serde_json", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59dc83cf45d89c555a577694534fcd1b55c545a816c816ce51f20bbe56a4f3f" +dependencies = [ + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "time", + "tracing", + "url", ] [[package]] @@ -2594,7 +2730,7 @@ checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall 0.3.5", + "redox_syscall", "rustix", "windows-sys", ] @@ -2795,7 +2931,19 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "toml" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.2", ] [[package]] @@ -2820,6 +2968,19 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.0.2", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "torrust-index" version = "3.0.0-alpha.1-develop" @@ -2859,7 +3020,7 @@ dependencies = [ "text-to-png", "thiserror", "tokio", - "toml 0.7.8", + "toml 0.8.2", "tower-http", "urlencoding", "uuid", @@ -2924,9 +3085,21 @@ dependencies = [ "cfg-if", "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "tracing-core" version = "0.1.31" @@ -3215,6 +3388,12 @@ dependencies = [ "rustix", ] +[[package]] +name = "whoami" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index c16b39e9..afbec95d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,31 +33,31 @@ version = "3.0.0-alpha.1-develop" opt-level = 3 [dependencies] -async-trait = "0.1" -futures = "0.3" -sqlx = { version = "0.6", features = [ +async-trait = "0" +futures = "0" +sqlx = { version = "0", features = [ "runtime-tokio-native-tls", "sqlite", "mysql", "migrate", "time", ] } -config = "0.13" -toml = "0.7" -derive_more = "0.99" -serde = { version = "1.0", features = ["rc"] } +config = "0" +toml = "0" +derive_more = "0" +serde = { version = "1", features = ["rc"] } serde_derive = "1" -serde_json = "1.0" -serde_bencode = "0.2.3" -serde_bytes = "0.11" -urlencoding = "2.1" -argon2 = "0.5" -rand_core = { version = "0.6", features = ["std"] } -chrono = { version = "0.4", default-features = false, features = ["clock"] } -jsonwebtoken = "8.3" -sha-1 = "0.10" -reqwest = { version = "0.11", features = ["json", "multipart"] } -tokio = { version = "1.28", features = [ +serde_json = "1" +serde_bencode = "0" +serde_bytes = "0" +urlencoding = "2" +argon2 = "0" +rand_core = { version = "0", features = ["std"] } +chrono = { version = "0", default-features = false, features = ["clock"] } +jsonwebtoken = "8" +sha-1 = "0" +reqwest = { version = "0", features = ["json", "multipart"] } +tokio = { version = "1", features = [ "macros", "io-util", "net", @@ -67,33 +67,33 @@ tokio = { version = "1.28", features = [ "sync", "signal", ] } -lettre = { version = "0.10", features = [ +lettre = { version = "0", features = [ "builder", "tokio1", "tokio1-rustls-tls", "tokio1-native-tls", "smtp-transport", ] } -sailfish = "0.6" -regex = "1.8" -pbkdf2 = { version = "0.12", features = ["simple"] } -text-colorizer = "1.0.0" -log = "0.4" -fern = "0.6" -bytes = "1.4" -text-to-png = "0.2" -indexmap = "1.9" -thiserror = "1.0" -binascii = "0.1" -axum = { version = "0.6.18", features = ["multipart"] } -hyper = "0.14.26" -tower-http = { version = "0.4.0", features = ["cors", "compression-full"] } -email_address = "0.2.4" -hex = "0.4.3" -uuid = { version = "1.3", features = ["v4"] } +sailfish = "0" +regex = "1" +pbkdf2 = { version = "0", features = ["simple"] } +text-colorizer = "1" +log = "0" +fern = "0" +bytes = "1" +text-to-png = "0" +indexmap = "1" +thiserror = "1" +binascii = "0" +axum = { version = "0", features = ["multipart"] } +hyper = "0" +tower-http = { version = "0", features = ["cors", "compression-full"] } +email_address = "0" +hex = "0" +uuid = { version = "1", features = ["v4"] } [dev-dependencies] -rand = "0.8" -tempfile = "3.5" -uuid = { version = "1.3", features = ["v4"] } -which = "4.4" +rand = "0" +tempfile = "3" +uuid = { version = "1", features = ["v4"] } +which = "4" diff --git a/src/databases/mysql.rs b/src/databases/mysql.rs index b57ad077..0c5175a6 100644 --- a/src/databases/mysql.rs +++ b/src/databases/mysql.rs @@ -32,8 +32,8 @@ impl Database for Mysql { } async fn new(database_url: &str) -> Self { - let mut connection_options = MySqlConnectOptions::from_str(database_url).expect("Unable to create connection options."); - connection_options + let connection_options = MySqlConnectOptions::from_str(database_url) + .expect("Unable to create connection options.") .log_statements(log::LevelFilter::Error) .log_slow_statements(log::LevelFilter::Warn, Duration::from_secs(1)); @@ -59,7 +59,7 @@ impl Database for Mysql { // create the user account and get the user id let user_id = query("INSERT INTO torrust_users (date_registered) VALUES (UTC_TIMESTAMP())") - .execute(&mut tx) + .execute(&mut *tx) .await .map(|v| v.last_insert_id()) .map_err(|_| database::Error::Error)?; @@ -68,7 +68,7 @@ impl Database for Mysql { let insert_user_auth_result = query("INSERT INTO torrust_user_authentication (user_id, password_hash) VALUES (?, ?)") .bind(user_id) .bind(password_hash) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|_| database::Error::Error); @@ -83,7 +83,7 @@ impl Database for Mysql { .bind(user_id) .bind(username) .bind(email) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|e| match e { sqlx::Error::Database(err) => { @@ -479,7 +479,7 @@ impl Database for Mysql { .bind(root_hash) .bind(torrent.info.source.clone()) .bind(torrent.comment.clone()) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|v| i64::try_from(v.last_insert_id()).expect("last ID is larger than i64")) .map_err(|e| match e { @@ -501,7 +501,7 @@ impl Database for Mysql { .bind(original_info_hash.to_hex_string()) .bind(canonical_info_hash.to_hex_string()) .bind(true) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|_| ()) .map_err(|err| { @@ -520,7 +520,7 @@ impl Database for Mysql { .bind(torrent.info.md5sum.clone()) .bind(torrent_id) .bind(length) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|_| ()) .map_err(|_| database::Error::Error) @@ -535,7 +535,7 @@ impl Database for Mysql { .bind(torrent_id) .bind(file.length) .bind(path) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|_| database::Error::Error)?; } @@ -558,7 +558,7 @@ impl Database for Mysql { let () = query("INSERT INTO torrust_torrent_announce_urls (torrent_id, tracker_url) VALUES (?, ?)") .bind(torrent_id) .bind(tracker_url) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|_| ()) .map_err(|_| database::Error::Error)?; @@ -571,7 +571,7 @@ impl Database for Mysql { query("INSERT INTO torrust_torrent_announce_urls (torrent_id, tracker_url) VALUES (?, ?)") .bind(torrent_id) .bind(tracker_url) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|_| ()) .map_err(|_| database::Error::Error) @@ -589,7 +589,7 @@ impl Database for Mysql { let insert_torrent_tag_result = query("INSERT INTO torrust_torrent_tag_links (torrent_id, tag_id) VALUES (?, ?)") .bind(torrent_id) .bind(tag_id) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|err| database::Error::ErrorWithText(err.to_string())); @@ -605,7 +605,7 @@ impl Database for Mysql { .bind(torrent_id) .bind(metadata.title.clone()) .bind(metadata.description.clone()) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|e| match e { sqlx::Error::Database(err) => { @@ -901,7 +901,7 @@ impl Database for Mysql { } async fn add_torrent_tag_links(&self, torrent_id: i64, tag_ids: &[TagId]) -> Result<(), database::Error> { - let mut transaction = self + let mut tx = self .pool .begin() .await @@ -911,13 +911,12 @@ impl Database for Mysql { query("INSERT INTO torrust_torrent_tag_links (torrent_id, tag_id) VALUES (?, ?)") .bind(torrent_id) .bind(tag_id) - .execute(&mut transaction) + .execute(&mut *tx) .await .map_err(|err| database::Error::ErrorWithText(err.to_string()))?; } - transaction - .commit() + tx.commit() .await .map_err(|err| database::Error::ErrorWithText(err.to_string())) } diff --git a/src/databases/sqlite.rs b/src/databases/sqlite.rs index 8e12f9be..02abfc24 100644 --- a/src/databases/sqlite.rs +++ b/src/databases/sqlite.rs @@ -32,8 +32,8 @@ impl Database for Sqlite { } async fn new(database_url: &str) -> Self { - let mut connection_options = SqliteConnectOptions::from_str(database_url).expect("Unable to create connection options."); - connection_options + let connection_options = SqliteConnectOptions::from_str(database_url) + .expect("Unable to create connection options.") .log_statements(log::LevelFilter::Error) .log_slow_statements(log::LevelFilter::Warn, Duration::from_secs(1)); @@ -60,7 +60,7 @@ impl Database for Sqlite { // create the user account and get the user id let user_id = query("INSERT INTO torrust_users (date_registered) VALUES (strftime('%Y-%m-%d %H:%M:%S',DATETIME('now', 'utc')))") - .execute(&mut tx) + .execute(&mut *tx) .await .map(|v| v.last_insert_rowid()) .map_err(|_| database::Error::Error)?; @@ -69,7 +69,7 @@ impl Database for Sqlite { let insert_user_auth_result = query("INSERT INTO torrust_user_authentication (user_id, password_hash) VALUES (?, ?)") .bind(user_id) .bind(password_hash) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|_| database::Error::Error); @@ -84,7 +84,7 @@ impl Database for Sqlite { .bind(user_id) .bind(username) .bind(email) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|e| match e { sqlx::Error::Database(err) => { @@ -469,7 +469,7 @@ impl Database for Sqlite { .bind(root_hash) .bind(torrent.info.source.clone()) .bind(torrent.comment.clone()) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|v| v.last_insert_rowid()) .map_err(|e| match e { @@ -491,7 +491,7 @@ impl Database for Sqlite { .bind(original_info_hash.to_hex_string()) .bind(canonical_info_hash.to_hex_string()) .bind(true) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|_| ()) .map_err(|err| { @@ -510,7 +510,7 @@ impl Database for Sqlite { .bind(torrent.info.md5sum.clone()) .bind(torrent_id) .bind(length) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|_| ()) .map_err(|_| database::Error::Error) @@ -525,7 +525,7 @@ impl Database for Sqlite { .bind(torrent_id) .bind(file.length) .bind(path) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|_| database::Error::Error)?; } @@ -548,7 +548,7 @@ impl Database for Sqlite { let () = query("INSERT INTO torrust_torrent_announce_urls (torrent_id, tracker_url) VALUES (?, ?)") .bind(torrent_id) .bind(tracker_url) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|_| ()) .map_err(|_| database::Error::Error)?; @@ -561,7 +561,7 @@ impl Database for Sqlite { query("INSERT INTO torrust_torrent_announce_urls (torrent_id, tracker_url) VALUES (?, ?)") .bind(torrent_id) .bind(tracker_url) - .execute(&mut tx) + .execute(&mut *tx) .await .map(|_| ()) .map_err(|_| database::Error::Error) @@ -579,7 +579,7 @@ impl Database for Sqlite { let insert_torrent_tag_result = query("INSERT INTO torrust_torrent_tag_links (torrent_id, tag_id) VALUES (?, ?)") .bind(torrent_id) .bind(tag_id) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|err| database::Error::ErrorWithText(err.to_string())); @@ -595,7 +595,7 @@ impl Database for Sqlite { .bind(torrent_id) .bind(metadata.title.clone()) .bind(metadata.description.clone()) - .execute(&mut tx) + .execute(&mut *tx) .await .map_err(|e| match e { sqlx::Error::Database(err) => { @@ -889,7 +889,7 @@ impl Database for Sqlite { } async fn add_torrent_tag_links(&self, torrent_id: i64, tag_ids: &[TagId]) -> Result<(), database::Error> { - let mut transaction = self + let mut tx = self .pool .begin() .await @@ -899,13 +899,12 @@ impl Database for Sqlite { query("INSERT INTO torrust_torrent_tag_links (torrent_id, tag_id) VALUES (?, ?)") .bind(torrent_id) .bind(tag_id) - .execute(&mut transaction) + .execute(&mut *tx) .await .map_err(|err| database::Error::ErrorWithText(err.to_string()))?; } - transaction - .commit() + tx.commit() .await .map_err(|err| database::Error::ErrorWithText(err.to_string())) }