Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bzip2 = "0.6.0"
getrandom = "0.3.1"
itertools = { version = "0.14.0" }
hex = "0.4.3"
derive_more = { version = "2.0.0", features = ["display", "deref", "from", "into"] }
derive_more = { version = "2.0.0", features = ["display", "deref", "from", "into", "from_str"] }
sysinfo = { version = "0.37.2", default-features = false, features = ["system"] }
derive_builder = "0.20.2"

Expand Down
7 changes: 5 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ sqlx-prepare ADDITIONAL_ARGS="":
sqlx-check:
just sqlx-prepare "--check"

lint:
cargo clippy --all-features --all-targets --workspace --locked -- -D warnings
lint *args:
cargo clippy --all-features --all-targets --workspace --locked {{ args }} -- -D warnings

lint-fix:
just lint --fix --allow-dirty --allow-staged

lint-js *args:
deno run -A npm:eslint@9 static templates gui-tests eslint.config.js {{ args }}
34 changes: 33 additions & 1 deletion src/bin/cratesfyi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{Context as _, Result, anyhow};
use clap::{Parser, Subcommand, ValueEnum};
use docs_rs::{
Config, Context, PackageKind, RustwideBuilder,
db::{self, CrateId, Overrides, add_path_into_database, types::version::Version},
db::{self, CrateId, Overrides, ReleaseId, add_path_into_database, types::version::Version},
start_background_metrics_webserver, start_web_server,
utils::{
ConfigName, get_config, get_crate_pattern_and_priority, list_crate_priorities,
Expand Down Expand Up @@ -531,6 +531,16 @@ enum DatabaseSubcommand {
/// Backfill GitHub/GitLab stats for crates.
BackfillRepositoryStats,

/// Recompress broken archive index files in storage.
RecompressArchiveIndexes {
#[arg(long)]
min_release_id: Option<ReleaseId>,
#[arg(long)]
max_release_id: Option<ReleaseId>,
#[arg(long)]
concurrency: Option<u8>,
},

/// Updates info for a crate from the registry's API
UpdateCrateRegistryFields {
#[arg(name = "CRATE")]
Expand Down Expand Up @@ -619,6 +629,28 @@ impl DatabaseSubcommand {
db::update_crate_data_in_database(&mut conn, &name, &registry_data).await
})?,

Self::RecompressArchiveIndexes {
min_release_id,
max_release_id,
concurrency,
} => ctx.runtime.block_on(async move {
let mut conn = ctx.pool.get_async().await?;

let (checked, recompressed) = ctx
.async_storage
.recompress_index_files_in_bucket(
&mut conn,
min_release_id,
max_release_id,
concurrency.map(Into::into),
)
.await?;

println!("{} index files checked", checked);
println!("{} index files recompressed", recompressed);
Ok::<_, anyhow::Error>(())
})?,

Self::AddDirectory { directory } => {
ctx.runtime
.block_on(add_path_into_database(
Expand Down
4 changes: 2 additions & 2 deletions src/db/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use derive_more::Display;
use derive_more::{Display, FromStr};
use serde::{Deserialize, Serialize};

pub mod dependencies;
Expand All @@ -8,7 +8,7 @@ pub mod version;
#[sqlx(transparent)]
pub struct CrateId(pub i32);

#[derive(Debug, Clone, Copy, Display, PartialEq, Eq, Hash, Serialize, sqlx::Type)]
#[derive(Debug, Clone, Copy, Display, PartialEq, Eq, Hash, FromStr, Serialize, sqlx::Type)]
#[sqlx(transparent)]
pub struct ReleaseId(pub i32);

Expand Down
6 changes: 4 additions & 2 deletions src/storage/archive_index.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::error::Result;
use crate::storage::{FileRange, compression::CompressionAlgorithm};
use crate::{
error::Result,
storage::{FileRange, compression::CompressionAlgorithm},
};
use anyhow::{Context as _, bail};
use itertools::Itertools as _;
use sqlx::{Acquire as _, QueryBuilder, Row as _, Sqlite};
Expand Down
Loading
Loading