Skip to content

Commit 8b7c3e6

Browse files
authored
Merge pull request #329 from AOSC-Dev/oma-refresh-refactor
`oma-refresh` refactor
2 parents 8153cf0 + 31c0e8b commit 8b7c3e6

File tree

7 files changed

+421
-336
lines changed

7 files changed

+421
-336
lines changed

i18n/zh-CN/oma.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ tum-2 = 根据您指定的操作,oma 还需要对系统组件执行若干变
233233
security = 安全更新
234234
verify-error = 在验证 { $p } 的签名时遇到错误。
235235
sources-list-empty = 软件源配置为空。
236-
failed-refresh = 无法刷新软件源数据
236+
failed-refresh = 无法刷新软件源数据
237237
unsupported-sources-list = APT 软件源配置文件 { $p } 不受支持:仅支持单行 ({ $list }) 及 DEB822 ({ $sources }) 格式的配置文件。
238238
set-permission = 设置权限失败。
239239
open-file-as-write-mode = 无法打开文件为写模式。

oma-fetch/src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use checksum::Checksum;
55
use download::{EmptySource, SingleDownloader, SuccessSummary};
66
use futures::{Future, StreamExt};
77

8-
use reqwest::Client;
8+
use reqwest::{Client, Method, RequestBuilder};
9+
use tracing::debug;
910

1011
pub mod checksum;
1112
mod download;
@@ -272,3 +273,19 @@ impl DownloadManager<'_> {
272273
Ok(Summary { success, failed })
273274
}
274275
}
276+
277+
pub fn build_request_with_basic_auth(
278+
client: &Client,
279+
method: Method,
280+
auth: &Option<(String, String)>,
281+
url: &str,
282+
) -> RequestBuilder {
283+
let mut req = client.request(method, url);
284+
285+
if let Some((user, password)) = auth {
286+
debug!("auth user: {}", user);
287+
req = req.basic_auth(user, Some(password));
288+
}
289+
290+
req
291+
}

0 commit comments

Comments
 (0)