Skip to content

Commit

Permalink
Bump the dependencies group with 4 updates (#1566)
Browse files Browse the repository at this point in the history
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matthias <matthias@endler.dev>
  • Loading branch information
dependabot[bot] and mre authored Nov 12, 2024
1 parent 9dc4217 commit 2d35dcc
Show file tree
Hide file tree
Showing 11 changed files with 545 additions and 663 deletions.
1,123 changes: 494 additions & 629 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ path = "builder.rs"

[dependencies]
lychee-lib = { path = "../../lychee-lib", default-features = false }
tokio = { version = "1.41.0", features = ["full"] }
tokio = { version = "1.41.1", features = ["full"] }
regex = "1.11.1"
http = "1.0.0"
reqwest = { version = "0.12.9", default-features = false, features = ["gzip"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ path = "chain.rs"
async-trait = "0.1.83"
lychee-lib = { path = "../../lychee-lib", default-features = false }
reqwest = "0.12.9"
tokio = { version = "1.41.0", features = ["full"] }
tokio = { version = "1.41.1", features = ["full"] }

[features]
email-check = ["lychee-lib/email-check"]
Expand Down
2 changes: 1 addition & 1 deletion examples/client_pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ path = "client_pool.rs"
futures = "0.3.31"
tokio-stream = "0.1.16"
lychee-lib = { path = "../../lychee-lib", default-features = false }
tokio = { version = "1.41.0", features = ["full"] }
tokio = { version = "1.41.1", features = ["full"] }

[features]
email-check = ["lychee-lib/email-check"]
Expand Down
2 changes: 1 addition & 1 deletion examples/collect_links/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ path = "collect_links.rs"

[dependencies]
lychee-lib = { path = "../../lychee-lib", default-features = false }
tokio = { version = "1.41.0", features = ["full"] }
tokio = { version = "1.41.1", features = ["full"] }
regex = "1.11.1"
http = "1.0.0"
tokio-stream = "0.1.16"
Expand Down
2 changes: 1 addition & 1 deletion examples/extract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ path = "extract.rs"

[dependencies]
lychee-lib = { path = "../../lychee-lib", default-features = false }
tokio = { version = "1.41.0", features = ["full"] }
tokio = { version = "1.41.1", features = ["full"] }

[features]
email-check = ["lychee-lib/email-check"]
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ path = "simple.rs"

[dependencies]
lychee-lib = { path = "../../lychee-lib", default-features = false }
tokio = { version = "1.41.0", features = ["full"] }
tokio = { version = "1.41.1", features = ["full"] }

[features]
email-check = ["lychee-lib/email-check"]
Expand Down
7 changes: 4 additions & 3 deletions lychee-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ assert-json-diff = "2.0.2"
clap = { version = "4.5.20", features = ["env", "derive"] }
console = "0.15.8"
const_format = "0.2.33"
csv = "1.3.0"
csv = "1.3.1"
dashmap = { version = "6.1.0", features = ["serde"] }
env_logger = "0.11.5"
futures = "0.3.31"
Expand Down Expand Up @@ -51,16 +51,17 @@ serde_json = "1.0.132"
strum = { version = "0.26.3", features = ["derive"] }
supports-color = "3.0.1"
tabled = "0.16.0"
tokio = { version = "1.41.0", features = ["full"] }
tokio = { version = "1.41.1", features = ["full"] }
tokio-stream = "0.1.16"
toml = "0.8.19"
url = "2.5.2"

[dev-dependencies]
assert_cmd = "2.0.16"
cookie_store = "0.21.1"
predicates = "3.1.2"
pretty_assertions = "1.4.1"
tempfile = "3.13.0"
tempfile = "3.14.0"
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
"fmt",
"registry",
Expand Down
8 changes: 3 additions & 5 deletions lychee-bin/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod cli {
time::Duration,
};

use anyhow::anyhow;
use assert_cmd::Command;
use assert_json_diff::assert_json_include;
use http::StatusCode;
Expand Down Expand Up @@ -1662,7 +1663,6 @@ mod cli {
async fn test_cookie_jar() -> Result<()> {
// Create a random cookie jar file
let cookie_jar = NamedTempFile::new()?;

let mut cmd = main_command();
cmd.arg("--cookie-jar")
.arg(cookie_jar.path().to_str().unwrap())
Expand All @@ -1675,15 +1675,13 @@ mod cli {

// check that the cookie jar file contains the expected cookies
let file = std::fs::File::open(cookie_jar.path()).map(std::io::BufReader::new)?;
let cookie_store = reqwest_cookie_store::CookieStore::load_json(file).unwrap();
let cookie_store = cookie_store::serde::json::load(file)
.map_err(|e| anyhow!("Failed to load cookie jar: {e}"))?;
let all_cookies = cookie_store.iter_any().collect::<Vec<_>>();

assert!(!all_cookies.is_empty());
assert!(all_cookies.iter().all(|c| c.domain() == Some("google.com")));

Ok(())
}

#[test]
fn test_dump_inputs_glob_md() -> Result<()> {
let pattern = fixtures_path().join("**/*.md");
Expand Down
9 changes: 5 additions & 4 deletions lychee-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async-stream = "0.3.6"
async-trait = "0.1.83"
cached = "0.54.0"
check-if-email-exists = { version = "0.9.1", optional = true }
cookie_store = "0.21.1"
email_address = "0.2.9"
futures = "0.3.31"
glob = "0.3.1"
Expand All @@ -42,7 +43,7 @@ reqwest = { version = "0.12.9", default-features = false, features = [
"trust-dns",
"cookies",
] }
reqwest_cookie_store = "0.8.0"
reqwest_cookie_store = { version = "0.8.0", features = ["serde"] }
# Make build work on Apple Silicon.
# See https://github.com/briansmith/ring/issues/1163
# This is necessary for the homebrew build
Expand All @@ -52,8 +53,8 @@ secrecy = "0.10.3"
serde = { version = "1.0.214", features = ["derive"] }
serde_with = "3.8.1"
shellexpand = "3.1.0"
thiserror = "2.0.0"
tokio = { version = "1.41.0", features = ["full"] }
thiserror = "2.0.3"
tokio = { version = "1.41.1", features = ["full"] }
toml = "0.8.19"
typed-builder = "0.20.0"
url = { version = "2.5.3", features = ["serde"] }
Expand All @@ -64,7 +65,7 @@ features = ["runtime-tokio"]

[dev-dependencies]
doc-comment = "0.3.3"
tempfile = "3.13.0"
tempfile = "3.14.0"
wiremock = "0.6.2"
serde_json = "1.0.132"
rstest = "0.23.0"
Expand Down
49 changes: 33 additions & 16 deletions lychee-lib/src/types/cookies.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::io::ErrorKind as IoErrorKind;
use std::{path::PathBuf, sync::Arc};

use crate::{ErrorKind, Result};
use log::info;
use reqwest_cookie_store::{CookieStore as ReqwestCookieStore, CookieStoreMutex};
use std::io::ErrorKind as IoErrorKind;
use std::{path::PathBuf, sync::Arc};

/// A wrapper around `reqwest_cookie_store::CookieStore`
///
Expand All @@ -23,17 +22,31 @@ impl CookieJar {
/// # Errors
///
/// This function will return an error if
/// - the file cannot be opened or
/// - if the file is not valid JSON
/// - the file cannot be opened (except for `NotFound`) or
/// - if the file is not valid JSON in either new or legacy format
pub fn load(path: PathBuf) -> Result<Self> {
match std::fs::File::open(&path).map(std::io::BufReader::new) {
Ok(reader) => {
Ok(mut reader) => {
info!("Loading cookies from {}", path.display());
let inner = Arc::new(CookieStoreMutex::new(
ReqwestCookieStore::load_json(reader)
.map_err(|e| ErrorKind::Cookies(format!("Failed to load cookies: {e}")))?,
));
Ok(Self { path, inner })

// Try loading with new format first, fall back to legacy format
#[allow(clippy::single_match_else)]
let store = match cookie_store::serde::json::load(&mut reader) {
Ok(store) => store,
Err(_) => {
// Reopen file for legacy format attempt
let reader = std::fs::File::open(&path).map(std::io::BufReader::new)?;
#[allow(deprecated)]
ReqwestCookieStore::load_json(reader).map_err(|e| {
ErrorKind::Cookies(format!("Failed to load cookies: {e}"))
})?
}
};

Ok(Self {
path,
inner: Arc::new(CookieStoreMutex::new(store)),
})
}
// Create a new cookie store if the file does not exist
Err(e) if e.kind() == IoErrorKind::NotFound => Ok(Self {
Expand All @@ -56,19 +69,23 @@ impl CookieJar {
/// - if the file cannot be written to or
/// - if the file cannot be serialized to JSON
pub fn save(&self) -> Result<()> {
info!("Saving cookies to {}", self.path.display());
// Create parent directories if they don't exist
if let Some(parent) = self.path.parent() {
std::fs::create_dir_all(parent)?;
}
let mut file = std::fs::File::create(&self.path)?;
self.inner
let store = self
.inner
.lock()
.map_err(|e| ErrorKind::Cookies(format!("Failed to lock cookie store: {e}")))?
.save_json(&mut file)
.map_err(|e| ErrorKind::Cookies(format!("Failed to lock cookie store: {e}")))?;
cookie_store::serde::json::save(&store, &mut file)
.map_err(|e| ErrorKind::Cookies(format!("Failed to save cookies: {e}")))
}
}

// Deref to inner cookie store
impl std::ops::Deref for CookieJar {
type Target = Arc<CookieStoreMutex>;

fn deref(&self) -> &Self::Target {
&self.inner
}
Expand Down

0 comments on commit 2d35dcc

Please sign in to comment.