From: Nutomic Date: Fri, 20 Jan 2023 17:46:49 +0000 (+0100) Subject: Add feature to embed pictrs in lemmy binary (fixes #2627) (#2633) X-Git-Url: http://these/git/readmes/README.ja.md?a=commitdiff_plain;h=1eaf2c8a038afc143e6f495fe474119d90078236;p=lemmy.git Add feature to embed pictrs in lemmy binary (fixes #2627) (#2633) * Add feature to embed pictrs in lemmy binary (fixes #2627) * Add pictrs config * add protobuf Co-authored-by: Dessalines --- diff --git a/.dockerignore b/.dockerignore index b3bb4eb2..5982307c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,4 @@ api_tests ansible tests *.sh +pictrs \ No newline at end of file diff --git a/.drone.yml b/.drone.yml index b8617608..9df1405a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -29,6 +29,8 @@ steps: environment: CARGO_HOME: .cargo commands: + - apt-get update + - apt-get install -y --no-install-recommends protobuf-compiler libprotobuf-dev - rustup component add clippy - cargo clippy --workspace --tests --all-targets --all-features -- -D warnings -D deprecated -D clippy::perf -D clippy::complexity diff --git a/.gitignore b/.gitignore index 23e9c403..ea0a2585 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ query_testing/**/reports/*.json # API tests api_tests/node_modules + +# pictrs data +pictrs/ diff --git a/Cargo.lock b/Cargo.lock index 72876f85..67a8b5cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,7 +60,7 @@ dependencies = [ "futures-util", "log", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "smallvec", "tokio", @@ -84,6 +84,22 @@ dependencies = [ "tokio-util 0.7.4", ] +[[package]] +name = "actix-form-data" +version = "0.7.0-beta.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e721f3919cb43c566c0dbb6a9cb5ad5106ac42b6b3c0d21a7a3e762455de957a" +dependencies = [ + "actix-multipart", + "actix-rt", + "actix-web", + "futures-util", + "mime", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "actix-http" version = "3.2.2" @@ -129,6 +145,24 @@ dependencies = [ "syn 1.0.103", ] +[[package]] +name = "actix-multipart" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9edfb0e7663d7fe18c8d5b668c9c1bcf79176b1dcc9d4da9592503209a6bfb0" +dependencies = [ + "actix-utils", + "actix-web", + "bytes", + "derive_more", + "futures-core", + "httparse", + "local-waker", + "log", + "mime", + "twoway", +] + [[package]] name = "actix-router" version = "0.5.1" @@ -193,6 +227,7 @@ dependencies = [ "actix-service", "actix-utils", "futures-core", + "http", "log", "pin-project-lite", "tokio-rustls", @@ -294,6 +329,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -402,7 +446,7 @@ dependencies = [ "derive_builder 0.10.2", "diligent-date-parser", "never", - "quick-xml", + "quick-xml 0.22.0", ] [[package]] @@ -411,6 +455,40 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "awc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80ca7ff88063086d2e2c70b9f3b29b2fcd999bac68ac21731e66781970d68519" +dependencies = [ + "actix-codec", + "actix-http", + "actix-rt", + "actix-service", + "actix-tls", + "actix-utils", + "ahash", + "base64", + "bytes", + "cfg-if", + "derive_more", + "futures-core", + "futures-util", + "h2", + "http", + "itoa", + "log", + "mime", + "percent-encoding", + "pin-project-lite", + "rand 0.8.5", + "rustls", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", +] + [[package]] name = "axum" version = "0.5.17" @@ -506,6 +584,21 @@ dependencies = [ "uuid", ] +[[package]] +name = "backtrace" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide 0.6.2", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.1" @@ -521,7 +614,7 @@ dependencies = [ "async-trait", "futures-channel", "futures-util", - "parking_lot", + "parking_lot 0.12.1", "tokio", ] @@ -680,6 +773,43 @@ dependencies = [ "inout", ] +[[package]] +name = "clap" +version = "4.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" +dependencies = [ + "bitflags", + "clap_derive", + "clap_lex", + "is-terminal", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +dependencies = [ + "heck 0.4.0", + "proc-macro-error", + "proc-macro2 1.0.47", + "quote 1.0.21", + "syn 1.0.103", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "clokwerk" version = "0.3.5" @@ -699,6 +829,33 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "color-eyre" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -733,6 +890,25 @@ dependencies = [ "xdg", ] +[[package]] +name = "config" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d379af7f68bfc21714c6c7dea883544201741d2ce8274bb12fa54f89507f52a7" +dependencies = [ + "async-trait", + "json5", + "lazy_static", + "nom 7.1.1", + "pathdiff", + "ron", + "rust-ini", + "serde", + "serde_json", + "toml", + "yaml-rust", +] + [[package]] name = "console-api" version = "0.4.0" @@ -830,6 +1006,19 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-epoch" +version = "0.9.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + [[package]] name = "crossbeam-utils" version = "0.8.12" @@ -1008,7 +1197,7 @@ dependencies = [ "hashbrown", "lock_api", "once_cell", - "parking_lot_core", + "parking_lot_core 0.9.4", ] [[package]] @@ -1208,6 +1397,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dlv-list" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" + [[package]] name = "doku" version = "0.20.0" @@ -1363,12 +1558,43 @@ dependencies = [ "syn 1.0.103", ] +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "event-listener" version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "eyre" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "fallible-iterator" version = "0.2.0" @@ -1406,7 +1632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.5.4", ] [[package]] @@ -1439,6 +1665,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "funty" version = "1.1.0" @@ -1544,6 +1780,15 @@ dependencies = [ "slab", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.6" @@ -1576,6 +1821,12 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "gimli" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" + [[package]] name = "h2" version = "0.3.14" @@ -1595,6 +1846,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "hashbrown" version = "0.12.3" @@ -1641,6 +1898,21 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "hmac" version = "0.12.1" @@ -1927,6 +2199,12 @@ dependencies = [ "png", ] +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "indexmap" version = "1.9.1" @@ -1955,12 +2233,34 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys 0.42.0", +] + [[package]] name = "ipnet" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes", + "rustix", + "windows-sys 0.42.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -2005,6 +2305,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "json5" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" +dependencies = [ + "pest", + "pest_derive", + "serde", +] + [[package]] name = "jsonwebtoken" version = "8.1.1" @@ -2267,8 +2578,9 @@ dependencies = [ "lemmy_routes", "lemmy_utils", "opentelemetry 0.17.0", - "opentelemetry-otlp", - "parking_lot", + "opentelemetry-otlp 0.10.0", + "parking_lot 0.12.1", + "pict-rs", "rand 0.8.5", "reqwest", "reqwest-middleware", @@ -2276,8 +2588,9 @@ dependencies = [ "reqwest-tracing", "serde", "serde_json", + "tokio", "tracing", - "tracing-actix-web", + "tracing-actix-web 0.6.1", "tracing-error", "tracing-log", "tracing-opentelemetry 0.17.4", @@ -2304,7 +2617,7 @@ dependencies = [ "lettre", "once_cell", "openssl", - "parking_lot", + "parking_lot 0.12.1", "percent-encoding", "rand 0.8.5", "regex", @@ -2374,6 +2687,18 @@ dependencies = [ "cc", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "local-channel" version = "0.1.3" @@ -2512,6 +2837,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "migrations_internals" version = "2.0.0" @@ -2564,6 +2898,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.4" @@ -2692,7 +3035,7 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", ] @@ -2705,6 +3048,15 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239da7f290cfa979f43f85a8efeee9a8a76d0827c356d37f9d3d7254d6b537fb" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.16.0" @@ -2795,12 +3147,22 @@ dependencies = [ ] [[package]] -name = "opentelemetry-otlp" -version = "0.10.0" +name = "opentelemetry" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1a6ca9de4c8b00aa7f1a153bd76cb263287155cec642680d79d98706f3d28a" +checksum = "69d6c3d7288a106c0a363e4b0e8d308058d56902adefb16f4936f417ffef086e" dependencies = [ - "async-trait", + "opentelemetry_api", + "opentelemetry_sdk", +] + +[[package]] +name = "opentelemetry-otlp" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1a6ca9de4c8b00aa7f1a153bd76cb263287155cec642680d79d98706f3d28a" +dependencies = [ + "async-trait", "futures", "futures-util", "http", @@ -2809,15 +3171,118 @@ dependencies = [ "thiserror", "tokio", "tonic 0.6.2", - "tonic-build", + "tonic-build 0.6.2", +] + +[[package]] +name = "opentelemetry-otlp" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1c928609d087790fc936a1067bdc310ae702bdf3b090c3f281b713622c8bbde" +dependencies = [ + "async-trait", + "futures", + "futures-util", + "http", + "opentelemetry 0.18.0", + "opentelemetry-proto", + "prost 0.11.0", + "thiserror", + "tokio", + "tonic 0.8.2", +] + +[[package]] +name = "opentelemetry-proto" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61a2f56df5574508dd86aaca016c917489e589ece4141df1b5e349af8d66c28" +dependencies = [ + "futures", + "futures-util", + "opentelemetry 0.18.0", + "prost 0.11.0", + "tonic 0.8.2", + "tonic-build 0.8.4", +] + +[[package]] +name = "opentelemetry_api" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c24f96e21e7acc813c7a8394ee94978929db2bcc46cf6b5014fc612bf7760c22" +dependencies = [ + "fnv", + "futures-channel", + "futures-util", + "indexmap", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", +] + +[[package]] +name = "opentelemetry_sdk" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca41c4933371b61c2a2f214bf16931499af4ec90543604ec828f7a625c09113" +dependencies = [ + "async-trait", + "crossbeam-channel", + "dashmap", + "fnv", + "futures-channel", + "futures-executor", + "futures-util", + "once_cell", + "opentelemetry_api", + "percent-encoding", + "rand 0.8.5", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "ordered-multimap" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" +dependencies = [ + "dlv-list", + "hashbrown", ] +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + [[package]] name = "overload" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -2825,7 +3290,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.4", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", ] [[package]] @@ -2847,6 +3326,12 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "pem" version = "1.1.0" @@ -3010,6 +3495,60 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pict-rs" +version = "0.4.0-beta.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0e3978ae576cdd6a4e62676a581a8a9153c6b01c8b70ee93fc489de2684265" +dependencies = [ + "actix-form-data", + "actix-rt", + "actix-server", + "actix-web", + "anyhow", + "async-trait", + "awc", + "base64", + "clap", + "color-eyre", + "config", + "console-subscriber", + "dashmap", + "futures-util", + "hex", + "md-5", + "mime", + "num_cpus", + "once_cell", + "opentelemetry 0.18.0", + "opentelemetry-otlp 0.11.0", + "pin-project-lite", + "quick-xml 0.26.0", + "rusty-s3", + "serde", + "serde_cbor", + "serde_json", + "serde_urlencoded", + "sha2", + "sled", + "storage-path-generator", + "thiserror", + "time 0.3.15", + "tokio", + "tokio-util 0.7.4", + "toml", + "tracing", + "tracing-actix-web 0.7.1", + "tracing-awc", + "tracing-error", + "tracing-futures", + "tracing-log", + "tracing-opentelemetry 0.18.0", + "tracing-subscriber", + "url", + "uuid", +] + [[package]] name = "pin-project" version = "1.0.12" @@ -3057,7 +3596,7 @@ dependencies = [ "bitflags", "crc32fast", "flate2", - "miniz_oxide", + "miniz_oxide 0.5.4", ] [[package]] @@ -3110,6 +3649,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "prettyplease" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c8992a85d8e93a28bdf76137db888d3874e3b230dee5ed8bebac4c9f7617773" +dependencies = [ + "proc-macro2 1.0.47", + "syn 1.0.103", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -3192,6 +3741,28 @@ dependencies = [ "which", ] +[[package]] +name = "prost-build" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276470f7f281b0ed53d2ae42dd52b4a8d08853a3c70e7fe95882acbb98a6ae94" +dependencies = [ + "bytes", + "heck 0.4.0", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost 0.11.0", + "prost-types 0.11.1", + "regex", + "syn 1.0.103", + "tempfile", + "which", +] + [[package]] name = "prost-derive" version = "0.9.0" @@ -3248,6 +3819,26 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37dddbbe9df96afafcb8027fcf263971b726530e12f0787f620a7ba5b4846081" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quick-xml" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" version = "0.6.13" @@ -3538,6 +4129,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "ron" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" +dependencies = [ + "base64", + "bitflags", + "serde", +] + [[package]] name = "rosetta-build" version = "0.1.2" @@ -3567,9 +4169,25 @@ dependencies = [ "atom_syndication", "derive_builder 0.10.2", "never", - "quick-xml", + "quick-xml 0.22.0", +] + +[[package]] +name = "rust-ini" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" +dependencies = [ + "cfg-if", + "ordered-multimap", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc_version" version = "0.4.0" @@ -3579,6 +4197,20 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.42.0", +] + [[package]] name = "rustls" version = "0.20.7" @@ -3597,6 +4229,25 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +[[package]] +name = "rusty-s3" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13332fd1e9538328a80183b9c0bde0cd7065ad2c4405f56b855a51a0a37fffd4" +dependencies = [ + "base64", + "hmac", + "md-5", + "percent-encoding", + "quick-xml 0.24.1", + "serde", + "serde_json", + "sha2", + "time 0.3.15", + "url", + "zeroize", +] + [[package]] name = "ryu" version = "1.0.11" @@ -3693,6 +4344,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.147" @@ -3760,7 +4421,7 @@ dependencies = [ "futures", "lazy_static", "log", - "parking_lot", + "parking_lot 0.12.1", "serial_test_derive", ] @@ -3849,6 +4510,22 @@ dependencies = [ "autocfg", ] +[[package]] +name = "sled" +version = "0.34.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f96b4737c2ce5987354855aed3797279def4ebf734436c6aa4552cf8e169935" +dependencies = [ + "crc32fast", + "crossbeam-epoch", + "crossbeam-utils", + "fs2", + "fxhash", + "libc", + "log", + "parking_lot 0.11.2", +] + [[package]] name = "smallvec" version = "1.10.0" @@ -3888,6 +4565,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "storage-path-generator" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f11d35dae9818c4313649da4a97c8329e29357a7fe584526c1d78f5b63ef836" + [[package]] name = "string_cache" version = "0.8.4" @@ -3896,7 +4579,7 @@ checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" dependencies = [ "new_debug_unreachable", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "phf_shared 0.10.0", "precomputed-hash", "serde", @@ -4124,7 +4807,7 @@ dependencies = [ "memchr", "mio", "num_cpus", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", "socket2", @@ -4177,7 +4860,7 @@ dependencies = [ "futures-channel", "futures-util", "log", - "parking_lot", + "parking_lot 0.12.1", "percent-encoding", "phf 0.11.1", "pin-project-lite", @@ -4317,7 +5000,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757" dependencies = [ "proc-macro2 1.0.47", - "prost-build", + "prost-build 0.9.0", + "quote 1.0.21", + "syn 1.0.103", +] + +[[package]] +name = "tonic-build" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4" +dependencies = [ + "prettyplease", + "proc-macro2 1.0.47", + "prost-build 0.11.4", "quote 1.0.21", "syn 1.0.103", ] @@ -4398,6 +5094,20 @@ dependencies = [ "uuid", ] +[[package]] +name = "tracing-actix-web" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16c2a0c52b267d46ea9a46012a28b3513ce166c28eaeaa875829ed2f8debd19" +dependencies = [ + "actix-web", + "opentelemetry 0.18.0", + "pin-project", + "tracing", + "tracing-opentelemetry 0.18.0", + "uuid", +] + [[package]] name = "tracing-attributes" version = "0.1.23" @@ -4409,6 +5119,23 @@ dependencies = [ "syn 1.0.103", ] +[[package]] +name = "tracing-awc" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab0b57d9e4b25f3d5f17d705c11c13c333b26dc062c02a9dedfe6a26f750a99e" +dependencies = [ + "actix-http", + "actix-service", + "awc", + "bytes", + "futures-core", + "opentelemetry 0.18.0", + "pin-project-lite", + "tracing", + "tracing-opentelemetry 0.18.0", +] + [[package]] name = "tracing-core" version = "0.1.30" @@ -4477,6 +5204,30 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "tracing-opentelemetry" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21ebb87a95ea13271332df069020513ab70bdb5637ca42d6e492dc3bbbad48de" +dependencies = [ + "once_cell", + "opentelemetry 0.18.0", + "tracing", + "tracing-core", + "tracing-log", + "tracing-subscriber", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + [[package]] name = "tracing-subscriber" version = "0.3.16" @@ -4487,12 +5238,15 @@ dependencies = [ "nu-ansi-term", "once_cell", "regex", + "serde", + "serde_json", "sharded-slab", "smallvec", "thread_local", "tracing", "tracing-core", "tracing-log", + "tracing-serde", ] [[package]] @@ -4501,6 +5255,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +[[package]] +name = "twoway" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c57ffb460d7c24cd6eda43694110189030a3d1dfe418416d9468fd1c1d290b47" +dependencies = [ + "memchr", + "unchecked-index", +] + [[package]] name = "typed-arena" version = "1.7.0" @@ -4530,6 +5294,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +[[package]] +name = "unchecked-index" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" + [[package]] name = "unicase" version = "2.6.0" @@ -4986,6 +5756,15 @@ dependencies = [ "markup5ever 0.11.0", ] +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "zeroize" version = "1.5.7" diff --git a/Cargo.toml b/Cargo.toml index 8b62bedc..bf3dec59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,8 @@ strip = "symbols" debug = 0 [features] -console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", - "reqwest-tracing/opentelemetry_0_16"] +embed-pictrs = ["pict-rs"] +console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"] default = [] [workspace] @@ -144,3 +144,5 @@ actix-rt = "2.6" rand = { workspace = true } console-subscriber = { version = "0.1.8", optional = true } opentelemetry-otlp = { version = "0.10.0", optional = true } +pict-rs = { version = "0.4.0-beta.9", optional = true } +tokio.workspace = true diff --git a/config/defaults.hjson b/config/defaults.hjson index e2ad2b41..2f4fc57a 100644 --- a/config/defaults.hjson +++ b/config/defaults.hjson @@ -18,7 +18,7 @@ # Pictrs image server configuration. pictrs: { # Address where pictrs is available (for image hosting) - url: "http://pictrs:8080/" + url: "http://localhost:8080/" # Set a custom pictrs API key. ( Required for deleting images ) api_key: "string" } diff --git a/crates/utils/src/settings/structs.rs b/crates/utils/src/settings/structs.rs index d32f3dc2..e5dac10d 100644 --- a/crates/utils/src/settings/structs.rs +++ b/crates/utils/src/settings/structs.rs @@ -45,8 +45,8 @@ pub struct Settings { #[serde(default)] pub struct PictrsConfig { /// Address where pictrs is available (for image hosting) - #[default(Url::parse("http://pictrs:8080").expect("parse pictrs url"))] - #[doku(example = "http://pictrs:8080")] + #[default(Url::parse("http://localhost:8080").expect("parse pictrs url"))] + #[doku(example = "http://localhost:8080")] pub url: Url, /// Set a custom pictrs API key. ( Required for deleting images ) diff --git a/src/main.rs b/src/main.rs index 68294989..79a813c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,5 +4,31 @@ use lemmy_utils::{error::LemmyError, settings::SETTINGS}; #[actix_web::main] pub async fn main() -> Result<(), LemmyError> { init_logging(&SETTINGS.opentelemetry_url)?; - start_lemmy_server().await + #[cfg(not(feature = "embed-pictrs"))] + start_lemmy_server().await?; + #[cfg(feature = "embed-pictrs")] + { + pict_rs::ConfigSource::memory(serde_json::json!({ + "server": { + "address": "127.0.0.1:8080" + }, + "old_db": { + "path": "./pictrs/old" + }, + "repo": { + "type": "sled", + "path": "./pictrs/sled-repo" + }, + "store": { + "type": "filesystem", + "path": "./pictrs/files" + } + })) + .init::<&str>(None) + .expect("initialize pictrs config"); + let (lemmy, pictrs) = tokio::join!(start_lemmy_server(), pict_rs::run()); + lemmy?; + pictrs.expect("run pictrs"); + } + Ok(()) }