Skip to content

Commit 44e68e4

Browse files
committed
drop use_archive_storage config var and old non-archive build logic
1 parent 2f0865a commit 44e68e4

File tree

2 files changed

+8
-139
lines changed

2 files changed

+8
-139
lines changed

src/config.rs

-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ pub struct Config {
5454
// where do we want to store the locally cached index files
5555
// for the remote archives?
5656
pub(crate) local_archive_cache_path: PathBuf,
57-
pub(crate) use_archive_storage: bool,
5857

5958
// Content Security Policy
6059
pub(crate) csp_report_only: bool,
@@ -136,7 +135,6 @@ impl Config {
136135
"DOCSRS_ARCHIVE_INDEX_CACHE_PATH",
137136
PathBuf::from(".archive_cache"),
138137
)?,
139-
use_archive_storage: env("DOCSRS_USE_ARCHIVE_STORAGE", false)?,
140138

141139
rustwide_workspace: env("DOCSRS_RUSTWIDE_WORKSPACE", PathBuf::from(".workspace"))?,
142140
inside_docker: env("DOCSRS_DOCKER", false)?,

src/docbuilder/rustwide_builder.rs

+8-137
Original file line numberDiff line numberDiff line change
@@ -359,44 +359,24 @@ impl RustwideBuilder {
359359
&metadata,
360360
)?;
361361
}
362-
if self.config.use_archive_storage {
363-
let (_, new_alg) = add_path_into_remote_archive(
364-
&self.storage,
365-
&rustdoc_archive_path(name, version),
366-
local_storage.path(),
367-
)?;
368-
algs.insert(new_alg);
369-
} else {
370-
debug!("Adding documentation into database");
371-
let (_, new_algs) = add_path_into_database(
372-
&self.storage,
373-
&format!("rustdoc/{}/{}", name, version),
374-
local_storage.path(),
375-
)?;
376-
377-
algs.extend(new_algs);
378-
}
362+
let (_, new_alg) = add_path_into_remote_archive(
363+
&self.storage,
364+
&rustdoc_archive_path(name, version),
365+
local_storage.path(),
366+
)?;
367+
algs.insert(new_alg);
379368
};
380369

381370
// Store the sources even if the build fails
382371
debug!("adding sources into database");
383-
let files_list = if self.config.use_archive_storage {
372+
let files_list = {
384373
let (files_list, new_alg) = add_path_into_remote_archive(
385374
&self.storage,
386375
&source_archive_path(name, version),
387376
build.host_source_dir(),
388377
)?;
389378
algs.insert(new_alg);
390379
files_list
391-
} else {
392-
let prefix = format!("sources/{}/{}", name, version);
393-
let (files_list, new_algs) = add_path_into_database(
394-
&self.storage,
395-
&prefix,
396-
build.host_source_dir(),
397-
)?;
398-
algs.extend(new_algs);
399-
files_list
400380
};
401381

402382
let has_examples = build.host_source_dir().join("examples").is_dir();
@@ -432,7 +412,7 @@ impl RustwideBuilder {
432412
has_examples,
433413
algs,
434414
repository,
435-
self.config.use_archive_storage,
415+
true,
436416
)?;
437417

438418
if let Some(doc_coverage) = res.doc_coverage {
@@ -766,115 +746,6 @@ mod tests {
766746
let version = DUMMY_CRATE_VERSION;
767747
let default_target = "x86_64-unknown-linux-gnu";
768748

769-
assert!(env.config().include_default_targets);
770-
771-
let mut builder = RustwideBuilder::init(env).unwrap();
772-
builder
773-
.build_package(crate_, version, PackageKind::CratesIo)
774-
.map(|_| ())?;
775-
776-
// check release record in the db (default and other targets)
777-
let mut conn = env.db().conn();
778-
let rows = conn
779-
.query(
780-
"SELECT
781-
r.rustdoc_status,
782-
r.default_target,
783-
r.doc_targets,
784-
r.archive_storage,
785-
cov.total_items
786-
FROM
787-
crates as c
788-
INNER JOIN releases AS r ON c.id = r.crate_id
789-
LEFT OUTER JOIN doc_coverage AS cov ON r.id = cov.release_id
790-
WHERE
791-
c.name = $1 AND
792-
r.version = $2",
793-
&[&crate_, &version],
794-
)
795-
.unwrap();
796-
let row = rows.get(0).unwrap();
797-
798-
assert!(row.get::<_, bool>("rustdoc_status"));
799-
assert_eq!(row.get::<_, String>("default_target"), default_target);
800-
assert!(row.get::<_, Option<i32>>("total_items").is_some());
801-
assert!(!row.get::<_, bool>("archive_storage"));
802-
803-
let mut targets: Vec<String> = row
804-
.get::<_, Value>("doc_targets")
805-
.as_array()
806-
.unwrap()
807-
.iter()
808-
.map(|v| v.as_str().unwrap().to_owned())
809-
.collect();
810-
targets.sort();
811-
assert_eq!(
812-
targets,
813-
vec![
814-
"i686-pc-windows-msvc",
815-
"i686-unknown-linux-gnu",
816-
"x86_64-apple-darwin",
817-
"x86_64-pc-windows-msvc",
818-
"x86_64-unknown-linux-gnu",
819-
]
820-
);
821-
822-
let storage = env.storage();
823-
let web = env.frontend();
824-
825-
// sources exist
826-
assert!(storage.exists(&format!("sources/{}/{}/src/lib.rs", crate_, version))?);
827-
assert_success(
828-
&format!("/crate/{}/{}/source/src/lib.rs", crate_, version),
829-
web,
830-
)?;
831-
832-
let base = format!("rustdoc/{}/{}", crate_, version);
833-
834-
// default target was built and is accessible
835-
assert!(storage.exists(&format!("{}/{}/index.html", base, crate_path))?);
836-
assert_success(&format!("/{}/{}/{}", crate_, version, crate_path), web)?;
837-
838-
// other targets too
839-
for target in DEFAULT_TARGETS {
840-
let target_docs_present =
841-
storage.exists(&format!("{}/{}/{}/index.html", base, target, crate_path))?;
842-
843-
let target_url = format!(
844-
"/{}/{}/{}/{}/index.html",
845-
crate_, version, target, crate_path
846-
);
847-
848-
if target == &default_target {
849-
assert!(!target_docs_present);
850-
assert_redirect(
851-
&target_url,
852-
&format!("/{}/{}/{}/index.html", crate_, version, crate_path),
853-
web,
854-
)?;
855-
} else {
856-
assert!(target_docs_present);
857-
assert_success(&target_url, web)?;
858-
}
859-
}
860-
861-
Ok(())
862-
})
863-
}
864-
865-
#[test]
866-
#[ignore]
867-
fn test_build_crate_into_archive() {
868-
wrapper(|env| {
869-
let crate_ = DUMMY_CRATE_NAME;
870-
let crate_path = crate_.replace("-", "_");
871-
let version = DUMMY_CRATE_VERSION;
872-
let default_target = "x86_64-unknown-linux-gnu";
873-
874-
env.override_config(|config| {
875-
config.use_archive_storage = true;
876-
});
877-
878749
let mut builder = RustwideBuilder::init(env).unwrap();
879750
builder
880751
.build_package(crate_, version, PackageKind::CratesIo)

0 commit comments

Comments
 (0)