Skip to content

Commit

Permalink
Merge pull request #329 from AOSC-Dev/oma-refresh-refactor
Browse files Browse the repository at this point in the history
`oma-refresh` refactor
  • Loading branch information
eatradish authored Jan 22, 2025
2 parents 8153cf0 + 31c0e8b commit 8b7c3e6
Show file tree
Hide file tree
Showing 7 changed files with 421 additions and 336 deletions.
2 changes: 1 addition & 1 deletion i18n/zh-CN/oma.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ tum-2 = 根据您指定的操作,oma 还需要对系统组件执行若干变
security = 安全更新
verify-error = 在验证 { $p } 的签名时遇到错误。
sources-list-empty = 软件源配置为空。
failed-refresh = 无法刷新软件源数据
failed-refresh = 无法刷新软件源数据
unsupported-sources-list = APT 软件源配置文件 { $p } 不受支持:仅支持单行 ({ $list }) 及 DEB822 ({ $sources }) 格式的配置文件。
set-permission = 设置权限失败。
open-file-as-write-mode = 无法打开文件为写模式。
Expand Down
19 changes: 18 additions & 1 deletion oma-fetch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use checksum::Checksum;
use download::{EmptySource, SingleDownloader, SuccessSummary};
use futures::{Future, StreamExt};

use reqwest::Client;
use reqwest::{Client, Method, RequestBuilder};
use tracing::debug;

pub mod checksum;
mod download;
Expand Down Expand Up @@ -272,3 +273,19 @@ impl DownloadManager<'_> {
Ok(Summary { success, failed })
}
}

pub fn build_request_with_basic_auth(
client: &Client,
method: Method,
auth: &Option<(String, String)>,
url: &str,
) -> RequestBuilder {
let mut req = client.request(method, url);

if let Some((user, password)) = auth {
debug!("auth user: {}", user);
req = req.basic_auth(user, Some(password));
}

req
}
Loading

0 comments on commit 8b7c3e6

Please sign in to comment.