Skip to content

Commit 78d8bed

Browse files
committed
storage: use latest build id to invalidate cached local archive index files
1 parent ec9c026 commit 78d8bed

File tree

5 files changed

+131
-45
lines changed

5 files changed

+131
-45
lines changed

src/db/delete.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ fn delete_crate_from_database(conn: &mut Client, name: &str, crate_id: i32) -> R
174174
transaction.execute("DELETE FROM owner_rels WHERE cid = $1;", &[&crate_id])?;
175175
let has_library = transaction
176176
.query_one(
177-
"SELECT
178-
BOOL_OR(releases.is_library) AS has_library
177+
"SELECT
178+
BOOL_OR(releases.is_library) AS has_library
179179
FROM releases
180180
WHERE releases.crate_id = $1
181181
",
@@ -249,6 +249,7 @@ mod tests {
249249
assert!(env.storage().rustdoc_file_exists(
250250
pkg,
251251
version,
252+
0,
252253
&format!("{pkg}/index.html"),
253254
archive_storage
254255
)?);
@@ -266,6 +267,7 @@ mod tests {
266267
assert!(env.storage().rustdoc_file_exists(
267268
"package-2",
268269
"1.0.0",
270+
0,
269271
"package-2/index.html",
270272
archive_storage
271273
)?);
@@ -282,12 +284,14 @@ mod tests {
282284
assert!(!env.storage().rustdoc_file_exists(
283285
"package-1",
284286
"1.0.0",
287+
0,
285288
"package-1/index.html",
286289
archive_storage
287290
)?);
288291
assert!(!env.storage().rustdoc_file_exists(
289292
"package-1",
290293
"2.0.0",
294+
0,
291295
"package-1/index.html",
292296
archive_storage
293297
)?);
@@ -329,6 +333,7 @@ mod tests {
329333
assert!(env.storage().rustdoc_file_exists(
330334
"a",
331335
"1.0.0",
336+
0,
332337
"a/index.html",
333338
archive_storage
334339
)?);
@@ -358,6 +363,7 @@ mod tests {
358363
assert!(env.storage().rustdoc_file_exists(
359364
"a",
360365
"2.0.0",
366+
0,
361367
"a/index.html",
362368
archive_storage
363369
)?);
@@ -386,6 +392,7 @@ mod tests {
386392
assert!(!env.storage().rustdoc_file_exists(
387393
"a",
388394
"1.0.0",
395+
0,
389396
"a/index.html",
390397
archive_storage
391398
)?);
@@ -394,6 +401,7 @@ mod tests {
394401
assert!(env.storage().rustdoc_file_exists(
395402
"a",
396403
"2.0.0",
404+
0,
397405
"a/index.html",
398406
archive_storage
399407
)?);

src/docbuilder/rustwide_builder.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,15 +993,20 @@ mod tests {
993993
assert!(storage.exists(&source_archive)?, "{}", source_archive);
994994

995995
// default target was built and is accessible
996-
assert!(storage.exists_in_archive(&doc_archive, &format!("{crate_path}/index.html"))?);
996+
assert!(storage.exists_in_archive(
997+
&doc_archive,
998+
0,
999+
&format!("{crate_path}/index.html"),
1000+
)?);
9971001
assert_success(&format!("/{crate_}/{version}/{crate_path}"), web)?;
9981002

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

10031007
assert!(!storage.exists_in_archive(
10041008
&doc_archive,
1009+
0,
10051010
&format!("{default_target}/{crate_path}/index.html"),
10061011
)?);
10071012

@@ -1035,6 +1040,7 @@ mod tests {
10351040
}
10361041
let target_docs_present = storage.exists_in_archive(
10371042
&doc_archive,
1043+
0,
10381044
&format!("{target}/{crate_path}/index.html"),
10391045
)?;
10401046

@@ -1152,8 +1158,11 @@ mod tests {
11521158

11531159
let target = "x86_64-unknown-linux-gnu";
11541160
let crate_path = crate_.replace('-', "_");
1155-
let target_docs_present = storage
1156-
.exists_in_archive(&doc_archive, &format!("{target}/{crate_path}/index.html"))?;
1161+
let target_docs_present = storage.exists_in_archive(
1162+
&doc_archive,
1163+
0,
1164+
&format!("{target}/{crate_path}/index.html"),
1165+
)?;
11571166

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

0 commit comments

Comments
 (0)