From 7b9391f36e9e5667a0bd9bc03d7f45844354a93b Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Wed, 4 Feb 2026 22:47:44 +0100 Subject: [PATCH] Refactor: Remove unused imports and clean up redundant code - Eliminated unused imports across multiple modules, including `info`, `trace`, `warn`, `base64`, `PathBuf`, and `fs`. - Replaced mutable variable assignment with immutable in `populate_obsolete_db`. - Simplified loop variable handling in `pkg6depotd` shard handler. --- libips/src/image/catalog.rs | 3 --- libips/src/repository/shard_sync.rs | 4 ++-- libips/src/repository/sqlite_catalog.rs | 3 +-- pkg6depotd/src/http/handlers/shard.rs | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/libips/src/image/catalog.rs b/libips/src/image/catalog.rs index 73261a0..14e064e 100644 --- a/libips/src/image/catalog.rs +++ b/libips/src/image/catalog.rs @@ -1,15 +1,12 @@ use crate::actions::Manifest; use crate::fmri::Fmri; -use crate::repository::catalog::{CatalogManager, CatalogPart, PackageVersionEntry}; use lz4::{Decoder as Lz4Decoder, EncoderBuilder as Lz4EncoderBuilder}; use miette::Diagnostic; use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::fs; use std::io::{Cursor, Read, Write}; use std::path::{Path, PathBuf}; use thiserror::Error; -use tracing::{info, trace, warn}; /// Errors that can occur when working with the image catalog #[derive(Error, Debug, Diagnostic)] diff --git a/libips/src/repository/shard_sync.rs b/libips/src/repository/shard_sync.rs index a3605d8..2554b86 100644 --- a/libips/src/repository/shard_sync.rs +++ b/libips/src/repository/shard_sync.rs @@ -7,11 +7,11 @@ //! //! Downloads catalog shards from the repository server and verifies their integrity. -use crate::repository::sqlite_catalog::{ShardEntry, ShardIndex}; +use crate::repository::sqlite_catalog::ShardIndex; use miette::Diagnostic; use sha2::{Digest, Sha256}; use std::fs; -use std::path::{Path, PathBuf}; +use std::path::Path; use thiserror::Error; #[derive(Debug, Error, Diagnostic)] diff --git a/libips/src/repository/sqlite_catalog.rs b/libips/src/repository/sqlite_catalog.rs index 8e7ffe7..3480de3 100644 --- a/libips/src/repository/sqlite_catalog.rs +++ b/libips/src/repository/sqlite_catalog.rs @@ -12,7 +12,6 @@ use crate::actions::Manifest; use crate::fmri::Fmri; use crate::repository::catalog::CatalogManager; -use base64::Engine as _; use miette::Diagnostic; use rusqlite::Connection; use serde::{Deserialize, Serialize}; @@ -478,7 +477,7 @@ pub fn populate_active_db( /// Helper function for tests: mark a package as obsolete in obsolete.db. /// Creates tables if absent (idempotent). pub fn populate_obsolete_db(db_path: &Path, fmri: &Fmri) -> Result<(), ShardBuildError> { - let mut conn = Connection::open(db_path)?; + let conn = Connection::open(db_path)?; conn.execute_batch(OBSOLETE_SCHEMA)?; conn.execute( diff --git a/pkg6depotd/src/http/handlers/shard.rs b/pkg6depotd/src/http/handlers/shard.rs index b47e868..bedeb3c 100644 --- a/pkg6depotd/src/http/handlers/shard.rs +++ b/pkg6depotd/src/http/handlers/shard.rs @@ -80,7 +80,7 @@ pub async fn get_shard_blob( // Find which shard file corresponds to this hash let mut shard_path: Option = None; - for (name, entry) in &index.shards { + for (_name, entry) in &index.shards { if entry.sha256 == sha256 { shard_path = Some(shard_dir.join(&sha256)); break;