Skip to content

Commit d7c4c24

Browse files
committed
Don't rely on transparent decompression in list_aur
The current AUR package list code relies on the reqwest client library to transparently decompress the packages.gz file. This only works if the server provides the 'Content-Encoding: gzip" HTTP header, which appears to have changed recently. This patch explicitly decompresses the package list if no encoding information is provided by the server. Fixes: #1447 v2: blindly decompress with fall back on error, since reqwest strips the content encoding header when it transparently decompresses. Signed-off-by: Edwin Peer <[email protected]>
1 parent 789bead commit d7c4c24

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ regex = "1.11.1"
5757
signal-hook = "0.3.18"
5858
bitflags = "2.9.1"
5959
toml = { version = "0.8.23", features = ["preserve_order"] }
60+
flate2 = "1.1"
6061

6162
[profile.release]
6263
codegen-units = 1

src/sync.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use crate::config::Config;
22
use crate::pkgbuild::PkgbuildRepos;
33
use crate::{exec, print_error};
44

5-
use std::io::Write;
5+
use std::io::{Read, Write};
66

77
use anyhow::{anyhow, ensure, Context, Result};
8+
use flate2::read::GzDecoder;
89

910
use raur::Raur;
1011
use tr::tr;
@@ -105,6 +106,11 @@ pub async fn list_aur(config: &Config) -> Result<()> {
105106
ensure!(success, "get {}: {}", url, resp.status());
106107

107108
let data = resp.bytes().await?;
109+
let mut extracted = Vec::new();
110+
let data = match GzDecoder::new(&data[..]).read_to_end(&mut extracted) {
111+
Ok(_) => extracted.into(),
112+
Err(_) => data,
113+
};
108114

109115
let stdout = std::io::stdout();
110116
let mut stdout = stdout.lock();

0 commit comments

Comments
 (0)