Skip to content
Open
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
48 changes: 34 additions & 14 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion oma-fetch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ faster-hex = "0.10"
sha2 = "0.10"
futures = "0.3"
# FIXME: issue https://github.com/AOSC-Dev/oma/issues/547, workaround downgrade to 0.4.27
async-compression = { version = "=0.4.27", features = ["gzip", "xz", "futures-io", "bzip2", "zstd"] }
async-compression = { version = "=0.4.27", features = ["gzip", "xz", "futures-io", "bzip2", "zstd", "lz4"] }
# Note: Use the `uncheck_liblzma_version` feature here to force dynamic linking
# even with older liblzma (Ubuntu 22.04 uses 5.2.x). Be mindful, however, that
# async-compression depends on a different liblzma-rs than what is specified here.
Expand Down
12 changes: 9 additions & 3 deletions oma-fetch/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use std::{
time::Duration,
};

use async_compression::futures::bufread::{BzDecoder, GzipDecoder, XzDecoder, ZstdDecoder};
use async_compression::futures::bufread::{
BzDecoder, GzipDecoder, Lz4Decoder, LzmaDecoder, XzDecoder, ZstdDecoder,
};
use bon::bon;
use futures::{AsyncRead, TryStreamExt, io::BufReader};
use reqwest::{
Expand Down Expand Up @@ -476,8 +478,10 @@ impl<'a> SingleDownloader<'a> {
CompressFile::Xz => &mut XzDecoder::new(BufReader::new(bytes_stream)),
CompressFile::Gzip => &mut GzipDecoder::new(BufReader::new(bytes_stream)),
CompressFile::Bz2 => &mut BzDecoder::new(BufReader::new(bytes_stream)),
CompressFile::Nothing => &mut BufReader::new(bytes_stream),
CompressFile::Zstd => &mut ZstdDecoder::new(BufReader::new(bytes_stream)),
CompressFile::Lzma => &mut LzmaDecoder::new(BufReader::new(bytes_stream)),
CompressFile::Lz4 => &mut Lz4Decoder::new(BufReader::new(bytes_stream)),
CompressFile::Nothing => &mut BufReader::new(bytes_stream),
};

let mut reader = reader.compat();
Expand Down Expand Up @@ -632,8 +636,10 @@ impl<'a> SingleDownloader<'a> {
CompressFile::Xz => &mut XzDecoder::new(BufReader::new(from)),
CompressFile::Gzip => &mut GzipDecoder::new(BufReader::new(from)),
CompressFile::Bz2 => &mut BzDecoder::new(BufReader::new(from)),
CompressFile::Nothing => &mut BufReader::new(from),
CompressFile::Zstd => &mut ZstdDecoder::new(BufReader::new(from)),
CompressFile::Lzma => &mut LzmaDecoder::new(BufReader::new(from)),
CompressFile::Lz4 => &mut Lz4Decoder::new(BufReader::new(from)),
CompressFile::Nothing => &mut BufReader::new(from),
};

let mut reader = reader.compat();
Expand Down
51 changes: 2 additions & 49 deletions oma-fetch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,59 +46,12 @@ pub enum CompressFile {
Gzip,
Xz,
Zstd,
Lzma,
Lz4,
#[default]
Nothing,
}

// 压缩文件下载顺序:Zstd -> XZ -> Gzip -> Bz2 -> 未压缩
impl Ord for CompressFile {
fn cmp(&self, other: &Self) -> Ordering {
match self {
CompressFile::Bz2 => match other {
CompressFile::Bz2 => Ordering::Equal,
CompressFile::Gzip => Ordering::Less,
CompressFile::Xz => Ordering::Less,
CompressFile::Zstd => Ordering::Less,
CompressFile::Nothing => Ordering::Greater,
},
CompressFile::Gzip => match other {
CompressFile::Bz2 => Ordering::Greater,
CompressFile::Gzip => Ordering::Less,
CompressFile::Xz => Ordering::Less,
CompressFile::Zstd => Ordering::Less,
CompressFile::Nothing => Ordering::Greater,
},
CompressFile::Xz => match other {
CompressFile::Bz2 => Ordering::Greater,
CompressFile::Gzip => Ordering::Greater,
CompressFile::Xz => Ordering::Equal,
CompressFile::Zstd => Ordering::Less,
CompressFile::Nothing => Ordering::Greater,
},
CompressFile::Zstd => match other {
CompressFile::Bz2 => Ordering::Greater,
CompressFile::Gzip => Ordering::Greater,
CompressFile::Xz => Ordering::Greater,
CompressFile::Zstd => Ordering::Equal,
CompressFile::Nothing => Ordering::Greater,
},
CompressFile::Nothing => match other {
CompressFile::Bz2 => Ordering::Less,
CompressFile::Gzip => Ordering::Less,
CompressFile::Xz => Ordering::Less,
CompressFile::Zstd => Ordering::Less,
CompressFile::Nothing => Ordering::Equal,
},
}
}
}

impl PartialOrd for CompressFile {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl From<&str> for CompressFile {
fn from(s: &str) -> Self {
match s {
Expand Down
4 changes: 4 additions & 0 deletions oma-refresh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ default = ["aosc", "sequoia-nettle-backend", "rustls", "apt"]
tokio = { version = "1.28", default-features = false, features = ["rt-multi-thread"] }
flume = "0.11.1"
oma-utils = { version = "^0.12.0", path = "../oma-utils", features = ["dpkg"] }

[[example]]
name = "update"
required-features = ["apt"]
Loading
Loading