Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
eatradish committed Feb 21, 2025
1 parent 134b715 commit 4f77f23
Show file tree
Hide file tree
Showing 57 changed files with 162 additions and 164 deletions.
6 changes: 3 additions & 3 deletions oma-console/src/pager.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
io::{self, stderr, stdin, stdout, BufRead, ErrorKind, IsTerminal, Write},
io::{self, BufRead, ErrorKind, IsTerminal, Write, stderr, stdin, stdout},
time::{Duration, Instant},
};

Expand All @@ -8,16 +8,16 @@ use ansi_to_tui::IntoText;
use crossterm::{
event::{self, Event, KeyCode, KeyModifiers},
execute,
terminal::{enable_raw_mode, EnterAlternateScreen},
terminal::{EnterAlternateScreen, enable_raw_mode},
};
use ratatui::{
Frame, Terminal,
backend::{Backend, CrosstermBackend},
layout::{Alignment, Constraint, Layout},
restore,
style::{Color, Stylize},
text::Text,
widgets::{Block, Paragraph, Scrollbar, ScrollbarOrientation, ScrollbarState},
Frame, Terminal,
};
use termbg::Theme;
use tracing::debug;
Expand Down
4 changes: 2 additions & 2 deletions oma-console/src/print.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{borrow::Cow, collections::BTreeMap, time::Duration};

use console::{style, Color, StyledObject};
use console::{Color, StyledObject, style};
use termbg::Theme;
use tracing::{debug, field::Field, Level};
use tracing::{Level, debug, field::Field};
use tracing_subscriber::Layer;

pub use termbg;
Expand Down
6 changes: 1 addition & 5 deletions oma-console/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ impl Writer {
let len = self.get_length();

if let Some(limit) = self.limit_max_len {
if len < limit {
len
} else {
limit
}
if len < limit { len } else { limit }
} else {
len
}
Expand Down
2 changes: 1 addition & 1 deletion oma-contents/examples/list_files.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use oma_contents::searcher::{pure_search, Mode};
use oma_contents::searcher::{Mode, pure_search};

fn main() {
pure_search("/var/lib/apt/lists", Mode::Files, "apt", |(pkg, file)| {
Expand Down
2 changes: 1 addition & 1 deletion oma-contents/examples/list_files_rg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use oma_contents::searcher::{ripgrep_search, Mode};
use oma_contents::searcher::{Mode, ripgrep_search};

fn main() {
ripgrep_search("/var/lib/apt/lists", Mode::Files, "apt", |(pkg, file)| {
Expand Down
2 changes: 1 addition & 1 deletion oma-contents/src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use winnow::{combinator::separated, token::take_till, ModalResult, Parser};
use winnow::{ModalResult, Parser, combinator::separated, token::take_till};

use crate::OmaContentsError;

Expand Down
4 changes: 2 additions & 2 deletions oma-contents/src/searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::{
path::{Path, PathBuf},
process::{Command, Stdio},
sync::{
mpsc::{self, Sender},
Arc,
mpsc::{self, Sender},
},
thread,
};
Expand All @@ -17,7 +17,7 @@ use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use tracing::debug;
use zstd::Decoder;

use crate::{parser::parse_contents_single_line, OmaContentsError};
use crate::{OmaContentsError, parser::parse_contents_single_line};

const ZSTD_MAGIC: &[u8] = &[40, 181, 47, 253];
const LZ4_MAGIC: &[u8] = &[0x04, 0x22, 0x4d, 0x18];
Expand Down
2 changes: 1 addition & 1 deletion oma-fetch/examples/downloads.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::PathBuf;

use oma_fetch::{
checksum::Checksum, DownloadEntry, DownloadManager, DownloadSource, DownloadSourceType, Event,
DownloadEntry, DownloadManager, DownloadSource, DownloadSourceType, Event, checksum::Checksum,
};
use reqwest::ClientBuilder;

Expand Down
4 changes: 2 additions & 2 deletions oma-fetch/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use std::{

use async_compression::futures::bufread::{BzDecoder, GzipDecoder, XzDecoder, ZstdDecoder};
use bon::Builder;
use futures::{io::BufReader, AsyncRead, TryStreamExt};
use futures::{AsyncRead, TryStreamExt, io::BufReader};
use oma_utils::url_no_escape::url_no_escape;
use reqwest::{
header::{HeaderValue, ACCEPT_RANGES, CONTENT_LENGTH, RANGE},
Client, Method, RequestBuilder,
header::{ACCEPT_RANGES, CONTENT_LENGTH, HeaderValue, RANGE},
};
use snafu::{ResultExt, Snafu};
use tokio::{
Expand Down
2 changes: 1 addition & 1 deletion oma-fetch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{cmp::Ordering, path::PathBuf, time::Duration};

use bon::{builder, Builder};
use bon::{Builder, builder};
use checksum::Checksum;
use download::{EmptySource, SingleDownloader, SuccessSummary};
use futures::{Future, StreamExt};
Expand Down
4 changes: 2 additions & 2 deletions oma-history/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn connect_db<P: AsRef<Path>>(db_path: P, write: bool) -> HistoryResult<Conn
Ok(conn) => conn,
Err(e) => match e {
Error::SqliteFailure(err, _) if [1, 14].contains(&err.extended_code) => {
return Err(HistoryError::HistoryEmpty)
return Err(HistoryError::HistoryEmpty);
}
e => return Err(HistoryError::ConnectError(e)),
},
Expand Down Expand Up @@ -304,7 +304,7 @@ pub fn list_history(conn: &Connection) -> HistoryResult<Vec<HistoryEntry>> {
Ok(stmt) => stmt,
Err(e) => match e {
Error::SqliteFailure(err, _) if [1, 14].contains(&err.extended_code) => {
return Err(HistoryError::HistoryEmpty)
return Err(HistoryError::HistoryEmpty);
}
e => return Err(HistoryError::ConnectError(e)),
},
Expand Down
20 changes: 14 additions & 6 deletions oma-history/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use serde_json::Value;
use tracing::{debug, info, warn};

use crate::{
HistoryEntryInner, HistoryError, HistoryResult, InstallHistoryEntry, RemoveHistoryEntry,
INSERT_INSTALL_TABLE, INSERT_NEW_MAIN_TABLE, INSERT_REMOVE_DETAIL_TABLE, INSERT_REMOVE_TABLE,
HistoryEntryInner, HistoryError, HistoryResult, INSERT_INSTALL_TABLE, INSERT_NEW_MAIN_TABLE,
INSERT_REMOVE_DETAIL_TABLE, INSERT_REMOVE_TABLE, InstallHistoryEntry, RemoveHistoryEntry,
};

pub fn create_and_maybe_migration_from_oma_db_v2(conn: &Connection) -> HistoryResult<()> {
Expand Down Expand Up @@ -243,7 +243,9 @@ fn get_old_table(conn: &Connection) -> Result<Vec<OldTableEntry>, HistoryError>
) {
Ok(i) => i,
Err(e) => {
warn!("Unable to migrate a history database entry from unix timestamp {time}: {e}, skipping ...", );
warn!(
"Unable to migrate a history database entry from unix timestamp {time}: {e}, skipping ...",
);
debug!("install packages: {}", install_packages);
has_fail = true;
continue;
Expand Down Expand Up @@ -277,11 +279,15 @@ fn get_old_table(conn: &Connection) -> Result<Vec<OldTableEntry>, HistoryError>
if !res.is_empty() {
res
} else if is_clean_configure {
warn!("`oma purge' entries from the old history database cannot be migrated from unix timestamp {time}, skipping ...");
warn!(
"`oma purge' entries from the old history database cannot be migrated from unix timestamp {time}, skipping ..."
);
debug!("remove packages: {}", &remove_packages);
continue;
} else {
warn!("Unable to migrate a history database entry from unix timestamp {time}: {e}, skipping ...");
warn!(
"Unable to migrate a history database entry from unix timestamp {time}: {e}, skipping ..."
);
debug!("remove packages: {}", &remove_packages);
has_fail = true;
continue;
Expand All @@ -292,7 +298,9 @@ fn get_old_table(conn: &Connection) -> Result<Vec<OldTableEntry>, HistoryError>
let summary_type = match serde_json::from_str::<OldSummaryType>(&summary_type) {
Ok(s) => s,
Err(e) => {
warn!("Unable to migrate a history database entry from unix timestamp {time}: {e}, skipping ...", );
warn!(
"Unable to migrate a history database entry from unix timestamp {time}: {e}, skipping ...",
);
debug!("summary type: {}", &summary_type);
has_fail = true;
continue;
Expand Down
2 changes: 1 addition & 1 deletion oma-mirror/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
};

use ahash::HashMap;
use indexmap::{indexmap, IndexMap};
use indexmap::{IndexMap, indexmap};
use once_cell::sync::OnceCell;
use serde::{Deserialize, Serialize};
use snafu::{ResultExt, Snafu};
Expand Down
2 changes: 1 addition & 1 deletion oma-pm-operation-type/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::Display;

use bon::{builder, Builder};
use bon::{Builder, builder};
use num_enum::{FromPrimitive, IntoPrimitive};
use oma_utils::human_bytes::HumanBytes;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion oma-pm/examples/download_pkgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{path::Path, thread};

use apt_auth_config::AuthConfig;
use flume::unbounded;
use oma_fetch::{reqwest::ClientBuilder, Event};
use oma_fetch::{Event, reqwest::ClientBuilder};
use oma_pm::{
apt::{AptConfig, DownloadConfig, OmaApt, OmaAptArgs, OmaAptError},
matches::PackagesMatcher,
Expand Down
4 changes: 2 additions & 2 deletions oma-pm/examples/install_fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::{io::Write, thread};
use apt_auth_config::AuthConfig;
use flume::unbounded;
use oma_apt::util::{get_apt_progress_string, terminal_height, terminal_width};
use oma_fetch::{reqwest::ClientBuilder, Event};
use oma_fetch::{Event, reqwest::ClientBuilder};
use oma_pm::{
CommitNetworkConfig,
apt::{AptConfig, OmaApt, OmaAptArgs, OmaAptError, SummarySort},
matches::PackagesMatcher,
progress::InstallProgressManager,
CommitNetworkConfig,
};

struct MyInstallProgressManager;
Expand Down
8 changes: 4 additions & 4 deletions oma-pm/src/apt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ use std::{

use ahash::HashSet;
use apt_auth_config::AuthConfig;
use bon::{builder, Builder};
use bon::{Builder, builder};
pub use oma_apt::cache::Upgrade;
use std::future::Future;
use tokio::runtime::Runtime;
use zbus::Connection;

use oma_apt::{
DepFlags, Dependency, Package, PkgCurrentState, Version,
cache::{Cache, PackageSort},
error::{AptError, AptErrors},
new_cache,
progress::{AcquireProgress, InstallProgress},
raw::IntoRawIter,
records::RecordField,
util::DiskSpace,
DepFlags, Dependency, Package, PkgCurrentState, Version,
};

use oma_fetch::{checksum::ChecksumError, reqwest::Client, Event, Summary};
use oma_fetch::{Event, Summary, checksum::ChecksumError, reqwest::Client};
use oma_utils::{
dpkg::{get_selections, is_hold, DpkgError},
dpkg::{DpkgError, get_selections, is_hold},
human_bytes::HumanBytes,
};

Expand Down
2 changes: 1 addition & 1 deletion oma-pm/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use oma_apt::{
progress::{AcquireProgress, InstallProgress},
util::{apt_lock, apt_lock_inner, apt_unlock, apt_unlock_inner},
};
use oma_fetch::{reqwest::Client, Event, Summary};
use oma_fetch::{Event, Summary, reqwest::Client};
use oma_pm_operation_type::{InstallEntry, OmaOperation};
use std::io::Write;
use tracing::debug;
Expand Down
2 changes: 1 addition & 1 deletion oma-pm/src/dbus.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use zbus::{interface, proxy, Connection, Result};
use zbus::{Connection, Result, interface, proxy};

pub struct OmaBus {
pub status: Status,
Expand Down
4 changes: 2 additions & 2 deletions oma-pm/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::{borrow::Cow, future::Future, path::Path};

use oma_console::console;
use oma_fetch::{
checksum::Checksum, reqwest::Client, DownloadEntry, DownloadManager, DownloadSource,
DownloadSourceType, Event, Summary,
DownloadEntry, DownloadManager, DownloadSource, DownloadSourceType, Event, Summary,
checksum::Checksum, reqwest::Client,
};
use oma_pm_operation_type::InstallEntry;
use tracing::debug;
Expand Down
2 changes: 1 addition & 1 deletion oma-pm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub mod matches;
pub mod pkginfo;
pub mod progress;
pub mod search;
pub use oma_apt::error::AptErrors;
pub use oma_apt::PkgCurrentState;
pub use oma_apt::error::AptErrors;
pub use search::PackageStatus;
mod commit;
mod dbus;
Expand Down
6 changes: 3 additions & 3 deletions oma-pm/src/matches.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use std::{borrow::Cow, path::Path};

use bon::{builder, Builder};
use bon::{Builder, builder};
use cxx::UniquePtr;
use glob_match::glob_match;
use oma_apt::{
Package, Version,
cache::{Cache, PackageSort},
error::{AptError, AptErrors},
raw::{IntoRawIter, PkgIterator},
records::RecordField,
Package, Version,
};
use oma_utils::{
dpkg::{dpkg_arch, DpkgError},
dpkg::{DpkgError, dpkg_arch},
url_no_escape::url_no_escape,
};
use once_cell::sync::OnceCell;
Expand Down
2 changes: 1 addition & 1 deletion oma-pm/src/pkginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::fmt::Display;
use ahash::HashMap;
use cxx::UniquePtr;
use oma_apt::{
BaseDep, DepType, Dependency, Package, PackageFile, Version,
cache::Cache,
raw::{IntoRawIter, PkgIterator, VerIterator},
records::RecordField,
BaseDep, DepType, Dependency, Package, PackageFile, Version,
};
use oma_utils::human_bytes::HumanBytes;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion oma-pm/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use indexmap::map::Entry;
use indicium::simple::{Indexable, SearchIndex};
use memchr::memmem;
use oma_apt::{
Package,
cache::{Cache, PackageSort},
error::{AptError, AptErrors},
raw::{IntoRawIter, PkgIterator},
Package,
};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
Expand Down
Loading

0 comments on commit 4f77f23

Please sign in to comment.