From 793d3c0c7014c17561f1715c77f187f52ca3c637 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 23 Mar 2024 18:41:59 -0500 Subject: [PATCH 1/3] Cleanup temporary directory on launch by default --- defaults.toml | 3 ++- src/config/commandline.rs | 7 +++++++ src/config/defaults.rs | 2 ++ src/config/file.rs | 2 ++ src/lib.rs | 6 +++++- src/tmp_file.rs | 31 ++++++++++++++++++++++++------- 6 files changed, 42 insertions(+), 9 deletions(-) diff --git a/defaults.toml b/defaults.toml index 4b6802b..60abfa3 100644 --- a/defaults.toml +++ b/defaults.toml @@ -4,6 +4,7 @@ read_only = false danger_dummy_mode = false max_file_count = 1 temporary_directory = "/tmp" +cleanup_temporary_directory = true [client] timeout = 30 @@ -46,7 +47,7 @@ proxy = "7d" [media.magick] max_width = 10000 max_height = 10000 -max_area = 40000000 +max_area = 20000 memory = 256 map = 512 disk = 1024 diff --git a/src/config/commandline.rs b/src/config/commandline.rs index 035ecbd..d029709 100644 --- a/src/config/commandline.rs +++ b/src/config/commandline.rs @@ -55,6 +55,7 @@ impl Args { address, api_key, temporary_directory, + no_cleanup_temporary_directory, certificate, private_key, client_timeout, @@ -122,6 +123,7 @@ impl Args { danger_dummy_mode, max_file_count, temporary_directory, + cleanup_temporary_directory: !no_cleanup_temporary_directory, certificate, private_key, }; @@ -541,6 +543,7 @@ struct Server { max_file_count: Option, #[serde(skip_serializing_if = "Option::is_none")] temporary_directory: Option, + cleanup_temporary_directory: bool, #[serde(skip_serializing_if = "Option::is_none")] certificate: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -973,6 +976,10 @@ struct Run { #[arg(long)] temporary_directory: Option, + /// Whether to attempt to clean files left behind from a previous run of pict-rs + #[arg(long)] + no_cleanup_temporary_directory: bool, + /// The path to the TLS certificate. Both the certificate and the private_key must be specified /// to enable TLS #[arg(long)] diff --git a/src/config/defaults.rs b/src/config/defaults.rs index aec1d98..c23a77d 100644 --- a/src/config/defaults.rs +++ b/src/config/defaults.rs @@ -24,6 +24,7 @@ struct ServerDefaults { danger_dummy_mode: bool, max_file_count: u32, temporary_directory: PathBuf, + cleanup_temporary_directory: bool, } #[derive(Clone, Debug, serde::Serialize)] @@ -211,6 +212,7 @@ impl Default for ServerDefaults { danger_dummy_mode: false, max_file_count: 1, temporary_directory: std::env::temp_dir(), + cleanup_temporary_directory: true, } } } diff --git a/src/config/file.rs b/src/config/file.rs index 43b53bd..508878a 100644 --- a/src/config/file.rs +++ b/src/config/file.rs @@ -119,6 +119,8 @@ pub(crate) struct Server { pub(crate) temporary_directory: PathBuf, + pub(crate) cleanup_temporary_directory: bool, + #[serde(skip_serializing_if = "Option::is_none")] pub(crate) certificate: Option, diff --git a/src/lib.rs b/src/lib.rs index 5395e56..bc19baa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1924,7 +1924,11 @@ impl PictRsConfiguration { // describe all the metrics pict-rs produces init_metrics::init_metrics(); - let tmp_dir = TmpDir::init(&config.server.temporary_directory).await?; + let tmp_dir = TmpDir::init( + &config.server.temporary_directory, + config.server.cleanup_temporary_directory, + ) + .await?; let policy_dir = magick::write_magick_policy(&config.media, &tmp_dir).await?; let client = build_client()?; diff --git a/src/tmp_file.rs b/src/tmp_file.rs index 46e9c14..aacca9a 100644 --- a/src/tmp_file.rs +++ b/src/tmp_file.rs @@ -16,9 +16,17 @@ pub(crate) struct TmpDir { } impl TmpDir { - pub(crate) async fn init>(path: P) -> std::io::Result> { - let path = path.as_ref().join(Uuid::now_v7().to_string()); - tokio::fs::create_dir(&path).await?; + pub(crate) async fn init>(path: P, cleanup: bool) -> std::io::Result> { + let base_path = path.as_ref().join("pict-rs"); + + if cleanup && tokio::fs::metadata(&base_path).await.is_ok() { + tokio::fs::remove_dir_all(&base_path).await?; + } + + let path = base_path.join(Uuid::now_v7().to_string()); + + tokio::fs::create_dir_all(&path).await?; + Ok(Arc::new(TmpDir { path: Some(path) })) } @@ -47,8 +55,13 @@ impl TmpDir { } pub(crate) async fn cleanup(self: Arc) -> std::io::Result<()> { - if let Some(path) = Arc::into_inner(self).and_then(|mut this| this.path.take()) { - tokio::fs::remove_dir_all(path).await?; + if let Some(mut path) = Arc::into_inner(self).and_then(|mut this| this.path.take()) { + tokio::fs::remove_dir_all(&path).await?; + + if path.pop() { + // attempt to remove parent directory if it is empty + let _ = tokio::fs::remove_dir(path).await; + } } Ok(()) @@ -57,9 +70,13 @@ impl TmpDir { impl Drop for TmpDir { fn drop(&mut self) { - if let Some(path) = self.path.take() { + if let Some(mut path) = self.path.take() { tracing::warn!("TmpDir - Blocking remove of {path:?}"); - std::fs::remove_dir_all(path).expect("Removed directory"); + std::fs::remove_dir_all(&path).expect("Removed directory"); + if path.pop() { + // attempt to remove parent directory if it is empty + let _ = std::fs::remove_dir(path); + } } } } From bcc7773433280c98b3d8dfb882f92528c29c80d5 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 23 Mar 2024 18:49:48 -0500 Subject: [PATCH 2/3] Update dependencies (minor & point) --- Cargo.lock | 198 +++++++++++++++++++++++++++-------------------------- 1 file changed, 102 insertions(+), 96 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5704963..a272f4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,7 +8,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bytes", "futures-core", "futures-sink", @@ -48,7 +48,7 @@ dependencies = [ "actix-utils", "ahash", "base64", - "bitflags 2.4.2", + "bitflags 2.5.0", "bytes", "bytestring", "derive_more", @@ -232,9 +232,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -317,9 +317,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "async-stream" @@ -340,18 +340,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -413,9 +413,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -475,9 +475,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" dependencies = [ "serde", ] @@ -511,9 +511,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "bytestring" @@ -550,9 +550,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.2" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ "clap_builder", "clap_derive", @@ -572,14 +572,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.0" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -590,9 +590,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "color-eyre" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" dependencies = [ "backtrace", "color-spantrace", @@ -802,11 +802,11 @@ dependencies = [ [[package]] name = "diesel" -version = "2.1.4" +version = "2.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62c6fcf842f17f8c78ecf7c81d75c5ce84436b41ee07e03f490fbb5f5a8731d8" +checksum = "03fc05c17098f21b89bc7d98fe1dd3cce2c11c2ad8e145f2a44fe08ed28eb559" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "byteorder", "diesel_derives", "itoa", @@ -836,22 +836,22 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81c5131a2895ef64741dad1d483f358c2a229a3a2d1b256778cdc5e146db64d4" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] name = "diesel_derives" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8337737574f55a468005a83499da720f20c65586241ffea339db9ecdfd2b44" +checksum = "5d02eecb814ae714ffe61ddc2db2dd03e6c49a42e269b5001355500d431cce0c" dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -860,7 +860,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1019,7 +1019,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1098,9 +1098,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "h2" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" dependencies = [ "bytes", "fnv", @@ -1108,7 +1108,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.2.5", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -1149,6 +1149,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -1317,9 +1323,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1464,9 +1470,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "metrics" -version = "0.22.1" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd71d9db2e4287c3407fa04378b8c2ee570aebe0854431562cdd89ca091854f4" +checksum = "2be3cbd384d4e955b231c895ce10685e3d8260c5ccffae898c96c723b0772835" dependencies = [ "ahash", "portable-atomic", @@ -1480,7 +1486,7 @@ checksum = "9bf4e7146e30ad172c42c39b3246864bd2d3c6396780711a1baf749cfe423e21" dependencies = [ "base64", "hyper", - "indexmap 2.2.5", + "indexmap 2.2.6", "ipnet", "metrics", "metrics-util", @@ -1491,9 +1497,9 @@ dependencies = [ [[package]] name = "metrics-util" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece71ab046dcf45604e573329966ec1db5ff4b81cfa170a924ff4c959ab5451a" +checksum = "8b07a5eb561b8cbc16be2d216faf7757f9baf3bfb94dbb0fae3df8387a5bb47f" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -1894,7 +1900,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1976,9 +1982,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -2003,7 +2009,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2085,7 +2091,7 @@ version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] @@ -2128,7 +2134,7 @@ dependencies = [ "postgres", "regex", "serde", - "siphasher 1.0.0", + "siphasher 1.0.1", "thiserror", "time", "tokio", @@ -2148,14 +2154,14 @@ dependencies = [ "quote", "refinery-core", "regex", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -2197,9 +2203,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.25" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eea5a9eb898d3783f17c6407670e3592fd174cb81a10e51d4c37f49450b9946" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64", "bytes", @@ -2241,9 +2247,9 @@ dependencies = [ [[package]] name = "reqwest-middleware" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a3e86aa6053e59030e7ce2d2a3b258dd08fc2d337d52f73f6cb480f5858690" +checksum = "5a735987236a8e238bf0296c7e351b999c188ccc11477f311b82b55c93984216" dependencies = [ "anyhow", "async-trait", @@ -2256,9 +2262,9 @@ dependencies = [ [[package]] name = "reqwest-tracing" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0152176687dd5cfe7f507ac1cb1a491c679cfe483afd133a7db7aaea818bb3" +checksum = "190838e54153d7a7e2ea98851304b3ce92daeabf14c54d32b01b84a3e636f683" dependencies = [ "anyhow", "async-trait", @@ -2301,7 +2307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64", - "bitflags 2.4.2", + "bitflags 2.5.0", "serde", "serde_derive", ] @@ -2378,9 +2384,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" +checksum = "868e20fada228fefaf6b652e00cc73623d54f8171e7352c18bb281571f2d92da" [[package]] name = "rustls-webpki" @@ -2507,7 +2513,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2608,9 +2614,9 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "siphasher" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ac45299ccbd390721be55b412d41931911f654fa99e2cb8bfb57184b2061fe" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "sketches-ddsketch" @@ -2646,9 +2652,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" @@ -2735,9 +2741,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" dependencies = [ "proc-macro2", "quote", @@ -2752,20 +2758,20 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "system-configuration" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 2.4.2", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ "core-foundation-sys", "libc", @@ -2782,22 +2788,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2894,7 +2900,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2961,9 +2967,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -3001,9 +3007,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ "serde", "serde_spanned", @@ -3022,11 +3028,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.6" +version = "0.22.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -3154,7 +3160,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3311,9 +3317,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "atomic", "getrandom", @@ -3384,7 +3390,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-shared", ] @@ -3418,7 +3424,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3724,7 +3730,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3744,5 +3750,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] From 5f850f8c86a1a938f2458ae088dba28f90e5be02 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 23 Mar 2024 18:59:48 -0500 Subject: [PATCH 3/3] Prepare 0.5.10 release --- Cargo.lock | 2 +- Cargo.toml | 2 +- pict-rs.nix | 2 +- pict-rs.toml | 5 +++++ releases/0.5.10.md | 31 +++++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 releases/0.5.10.md diff --git a/Cargo.lock b/Cargo.lock index a272f4f..a44bb75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "pict-rs" -version = "0.5.9" +version = "0.5.10" dependencies = [ "actix-form-data", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index ca38916..ea61a6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pict-rs" description = "A simple image hosting service" -version = "0.5.9" +version = "0.5.10" authors = ["asonix "] license = "AGPL-3.0" readme = "README.md" diff --git a/pict-rs.nix b/pict-rs.nix index 4c4ebbc..4fb1bfc 100644 --- a/pict-rs.nix +++ b/pict-rs.nix @@ -11,7 +11,7 @@ rustPlatform.buildRustPackage { pname = "pict-rs"; - version = "0.5.9"; + version = "0.5.10"; src = ./.; cargoLock = { diff --git a/pict-rs.toml b/pict-rs.toml index e27990f..586c022 100644 --- a/pict-rs.toml +++ b/pict-rs.toml @@ -37,6 +37,11 @@ max_file_count = 1 # default: The system's advertised temporary directory ("/tmp" on most linuxes) temporary_directory = "/tmp" +## Optional: whether to delete the contents of $temporary_directory/pict-rs on launch +# environment variable: PICTRS__SERVER__CLEANUP_TEMPORARY_DIRECTORY +# default: true +cleanup_temporary_directory = true + ## Optional: path to server certificate to enable TLS # environment variable: PICTRS__SERVER__CERTIFICATE # default: empty diff --git a/releases/0.5.10.md b/releases/0.5.10.md new file mode 100644 index 0000000..413a797 --- /dev/null +++ b/releases/0.5.10.md @@ -0,0 +1,31 @@ +# pict-rs 0.5.10 + +## Overview + +pict-rs 0.5.10 is a small release with changes to how pict-rs handles temporary files. + +### Changes + +- [Temporary File Cleanup](#temporary-file-cleanup) + + +## Upgrade Notes + +There are no significant changes from 0.5.9. Upgrading should be as simple as pulling the new +version. + + +## Descriptions + +### Temporary File Cleanup + +pict-rs now nests its temporary files inside a `pict-rs` toplevel temporary folder. This is useful +because pict-rs 0.5.10 introduces a new behavior: it will completely delete that folder and its +contents on launch. If you are running multiple copies of pict-rs on the same host and they share +your temporary folder, this might cause problems. In that scenario, this behavior can be disabled by +setting `PICTRS__SERVER__CLEANUP_TEMPORARY_DIRECTORY=false` or passing +`--no-cleanup-temporary-directory` on the commandline. + +This new behavior has been introduced in order to better clean up after crashes. If pict-rs is +killed while processing media, maybe due to an OOM, it will leave files behind in the temporary +directory. This can cause the temporary directory to grow, leading to memory or disk problems.