Skip to content

Commit

Permalink
storage: use latest build id to invalidate cached local archive index…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
syphar committed Oct 14, 2023
1 parent c8154ee commit b149054
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 45 deletions.
12 changes: 10 additions & 2 deletions src/db/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ fn delete_crate_from_database(conn: &mut Client, name: &str, crate_id: i32) -> R
transaction.execute("DELETE FROM owner_rels WHERE cid = $1;", &[&crate_id])?;
let has_library = transaction
.query_one(
"SELECT
BOOL_OR(releases.is_library) AS has_library
"SELECT
BOOL_OR(releases.is_library) AS has_library
FROM releases
WHERE releases.crate_id = $1
",
Expand Down Expand Up @@ -249,6 +249,7 @@ mod tests {
assert!(env.storage().rustdoc_file_exists(
pkg,
version,
0,
&format!("{pkg}/index.html"),
archive_storage
)?);
Expand All @@ -266,6 +267,7 @@ mod tests {
assert!(env.storage().rustdoc_file_exists(
"package-2",
"1.0.0",
0,
"package-2/index.html",
archive_storage
)?);
Expand All @@ -282,12 +284,14 @@ mod tests {
assert!(!env.storage().rustdoc_file_exists(
"package-1",
"1.0.0",
0,
"package-1/index.html",
archive_storage
)?);
assert!(!env.storage().rustdoc_file_exists(
"package-1",
"2.0.0",
0,
"package-1/index.html",
archive_storage
)?);
Expand Down Expand Up @@ -329,6 +333,7 @@ mod tests {
assert!(env.storage().rustdoc_file_exists(
"a",
"1.0.0",
0,
"a/index.html",
archive_storage
)?);
Expand Down Expand Up @@ -358,6 +363,7 @@ mod tests {
assert!(env.storage().rustdoc_file_exists(
"a",
"2.0.0",
0,
"a/index.html",
archive_storage
)?);
Expand Down Expand Up @@ -386,6 +392,7 @@ mod tests {
assert!(!env.storage().rustdoc_file_exists(
"a",
"1.0.0",
0,
"a/index.html",
archive_storage
)?);
Expand All @@ -394,6 +401,7 @@ mod tests {
assert!(env.storage().rustdoc_file_exists(
"a",
"2.0.0",
0,
"a/index.html",
archive_storage
)?);
Expand Down
17 changes: 13 additions & 4 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,15 +994,20 @@ mod tests {
assert!(storage.exists(&source_archive)?, "{}", source_archive);

// default target was built and is accessible
assert!(storage.exists_in_archive(&doc_archive, &format!("{crate_path}/index.html"))?);
assert!(storage.exists_in_archive(
&doc_archive,
0,
&format!("{crate_path}/index.html"),
)?);
assert_success(&format!("/{crate_}/{version}/{crate_path}"), web)?;

// source is also packaged
assert!(storage.exists_in_archive(&source_archive, "src/lib.rs")?);
assert!(storage.exists_in_archive(&source_archive, 0, "src/lib.rs",)?);
assert_success(&format!("/crate/{crate_}/{version}/source/src/lib.rs"), web)?;

assert!(!storage.exists_in_archive(
&doc_archive,
0,
&format!("{default_target}/{crate_path}/index.html"),
)?);

Expand Down Expand Up @@ -1036,6 +1041,7 @@ mod tests {
}
let target_docs_present = storage.exists_in_archive(
&doc_archive,
0,
&format!("{target}/{crate_path}/index.html"),
)?;

Expand Down Expand Up @@ -1153,8 +1159,11 @@ mod tests {

let target = "x86_64-unknown-linux-gnu";
let crate_path = crate_.replace('-', "_");
let target_docs_present = storage
.exists_in_archive(&doc_archive, &format!("{target}/{crate_path}/index.html"))?;
let target_docs_present = storage.exists_in_archive(
&doc_archive,
0,
&format!("{target}/{crate_path}/index.html"),
)?;

let web = env.frontend();
let target_url = format!("/{crate_}/{version}/{target}/{crate_path}/index.html");
Expand Down
Loading

0 comments on commit b149054

Please sign in to comment.