Skip to content

Commit 3a8a857

Browse files
committed
don't compress json twice
1 parent 2a68f20 commit 3a8a857

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/docbuilder/rustwide_builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,8 @@ impl RustwideBuilder {
923923
let _span = info_span!("store_json", %format_version).entered();
924924
let path = rustdoc_json_path(name, version, target, format_version);
925925

926-
self.storage.store_one(&path, compressed_json.clone())?;
926+
self.storage
927+
.store_one_uncompressed(&path, compressed_json.clone())?;
927928
self.storage.set_public_access(&path, true)?;
928929
}
929930

src/storage/mod.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,30 @@ impl AsyncStorage {
569569
Ok(alg)
570570
}
571571

572+
// Store file without compressing, assumes it's already compressed
573+
#[instrument(skip(self, content))]
574+
pub(crate) async fn store_one_uncompressed(
575+
&self,
576+
path: impl Into<String> + std::fmt::Debug,
577+
content: impl Into<Vec<u8>>,
578+
) -> Result<()> {
579+
let path = path.into();
580+
let content = content.into();
581+
let mime = detect_mime(&path).to_owned();
582+
583+
self.store_inner(vec![Blob {
584+
path,
585+
mime,
586+
content,
587+
compression: None,
588+
// this field is ignored by the backend
589+
date_updated: Utc::now(),
590+
}])
591+
.await?;
592+
593+
Ok(())
594+
}
595+
572596
async fn store_inner(&self, batch: Vec<Blob>) -> Result<()> {
573597
match &self.backend {
574598
StorageBackend::Database(db) => db.store_batch(batch).await,
@@ -777,6 +801,16 @@ impl Storage {
777801
self.runtime.block_on(self.inner.store_one(path, content))
778802
}
779803

804+
#[instrument(skip(self, content))]
805+
pub(crate) async fn store_one_uncompressed(
806+
&self,
807+
path: impl Into<String> + std::fmt::Debug,
808+
content: impl Into<Vec<u8>>,
809+
) -> Result<()> {
810+
self.runtime
811+
.block_on(self.inner.store_one_uncompressed(path, content))
812+
}
813+
780814
/// sync wrapper for the list_prefix function
781815
/// purely for testing purposes since it collects all files into a Vec.
782816
#[cfg(test)]

0 commit comments

Comments
 (0)