Skip to content

Commit 59b56d7

Browse files
committed
chore(client): remove api that are now unused with the last refactor
1 parent efd41b7 commit 59b56d7

File tree

1 file changed

+1
-85
lines changed

1 file changed

+1
-85
lines changed

mithril-client/src/file_downloader/interface.rs

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
use std::{collections::HashMap, path::Path};
1+
use std::path::Path;
22

33
use anyhow::anyhow;
44
use async_trait::async_trait;
55

66
use mithril_common::{
77
entities::{
88
AncillaryLocation, CompressionAlgorithm, DigestLocation, FileUri, ImmutableFileNumber,
9-
ImmutablesLocation,
109
},
1110
StdError, StdResult,
1211
};
@@ -21,39 +20,6 @@ pub enum FileDownloaderUri {
2120
}
2221

2322
impl FileDownloaderUri {
24-
/// Expand the immutable locations to a list of file URIs
25-
pub fn expand_immutable_files_location_to_file_downloader_uris(
26-
immutable_files_location: &ImmutablesLocation,
27-
immutable_files_range: &[ImmutableFileNumber],
28-
) -> StdResult<Vec<(ImmutableFileNumber, FileDownloaderUri)>> {
29-
match immutable_files_location {
30-
ImmutablesLocation::CloudStorage {
31-
uri,
32-
compression_algorithm: _,
33-
} => {
34-
let expand_variables = immutable_files_range
35-
.iter()
36-
.map(|immutable_file_number| {
37-
HashMap::from([(
38-
"immutable_file_number".to_string(),
39-
format!("{:05}", immutable_file_number),
40-
)])
41-
})
42-
.collect();
43-
let file_downloader_uris = uri
44-
.expand_to_file_uris(expand_variables)?
45-
.into_iter()
46-
.map(FileDownloaderUri::FileUri);
47-
let immutable_files_range = immutable_files_range.iter().copied();
48-
49-
Ok(immutable_files_range.zip(file_downloader_uris).collect())
50-
}
51-
ImmutablesLocation::Unknown => {
52-
Err(anyhow!("Unknown location type to download immutable"))
53-
}
54-
}
55-
}
56-
5723
/// Get the URI as a string
5824
pub fn as_str(&self) -> &str {
5925
match self {
@@ -271,58 +237,8 @@ pub trait FileDownloader: Sync + Send {
271237

272238
#[cfg(test)]
273239
mod tests {
274-
use mithril_common::entities::{MultiFilesUri, TemplateUri};
275-
276240
use super::*;
277241

278-
#[test]
279-
fn immutable_files_location_to_file_downloader_uris() {
280-
let immutable_files_location = ImmutablesLocation::CloudStorage {
281-
uri: MultiFilesUri::Template(TemplateUri(
282-
"http://whatever/{immutable_file_number}.tar.gz".to_string(),
283-
)),
284-
compression_algorithm: Some(CompressionAlgorithm::Gzip),
285-
};
286-
let immutable_files_range: Vec<ImmutableFileNumber> = (1..=3).collect();
287-
288-
let file_downloader_uris =
289-
FileDownloaderUri::expand_immutable_files_location_to_file_downloader_uris(
290-
&immutable_files_location,
291-
&immutable_files_range,
292-
)
293-
.unwrap();
294-
295-
assert_eq!(
296-
file_downloader_uris,
297-
vec![
298-
(
299-
1,
300-
FileDownloaderUri::FileUri(FileUri("http://whatever/00001.tar.gz".to_string()))
301-
),
302-
(
303-
2,
304-
FileDownloaderUri::FileUri(FileUri("http://whatever/00002.tar.gz".to_string()))
305-
),
306-
(
307-
3,
308-
FileDownloaderUri::FileUri(FileUri("http://whatever/00003.tar.gz".to_string()))
309-
),
310-
]
311-
);
312-
}
313-
314-
#[test]
315-
fn immutable_files_location_to_file_downloader_uris_return_error_when_location_is_unknown() {
316-
let immutable_files_location = ImmutablesLocation::Unknown;
317-
let immutable_files_range: Vec<ImmutableFileNumber> = (1..=1).collect();
318-
319-
FileDownloaderUri::expand_immutable_files_location_to_file_downloader_uris(
320-
&immutable_files_location,
321-
&immutable_files_range,
322-
)
323-
.expect_err("expand_immutable_files_location_to_file_downloader_uris should fail");
324-
}
325-
326242
#[test]
327243
fn download_event_type_builds_started_event() {
328244
let download_event_type = DownloadEvent::Immutable {

0 commit comments

Comments
 (0)