forked from Proxmox/proxmox
fallback to Release file for Origin retrieval
APT will not store the InRelease file in some cases, and some repositories might not even have one in the first place. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
35dc1b0b8d
commit
27cd025053
@ -323,11 +323,14 @@ impl APTRepository {
|
||||
pub fn get_cached_origin(&self) -> Result<Option<String>, Error> {
|
||||
for uri in self.uris.iter() {
|
||||
for suite in self.suites.iter() {
|
||||
let file = in_release_filename(uri, suite);
|
||||
let mut file = release_filename(uri, suite, false);
|
||||
|
||||
if !file.exists() {
|
||||
file = release_filename(uri, suite, true);
|
||||
if !file.exists() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let raw = std::fs::read(&file)
|
||||
.map_err(|err| format_err!("unable to read {:?} - {}", file, err))?;
|
||||
@ -362,17 +365,19 @@ impl APTRepository {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the path to the cached InRelease file.
|
||||
fn in_release_filename(uri: &str, suite: &str) -> PathBuf {
|
||||
/// Get the path to the cached (In)Release file.
|
||||
fn release_filename(uri: &str, suite: &str, detached: bool) -> PathBuf {
|
||||
let mut path = PathBuf::from(&crate::config::get().dir_state);
|
||||
path.push(&crate::config::get().dir_state_lists);
|
||||
|
||||
let filename = uri_to_filename(uri);
|
||||
let encoded_uri = uri_to_filename(uri);
|
||||
let filename = if detached { "Release" } else { "InRelease" };
|
||||
|
||||
path.push(format!(
|
||||
"{}_dists_{}_InRelease",
|
||||
filename,
|
||||
"{}_dists_{}_{}",
|
||||
encoded_uri,
|
||||
suite.replace('/', "_"), // e.g. for buster/updates
|
||||
filename,
|
||||
));
|
||||
|
||||
path
|
||||
|
Loading…
Reference in New Issue
Block a user