Skip to content

Commit a3d07d3

Browse files
committed
wip
1 parent 5ec4326 commit a3d07d3

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

src/web/build_details.rs

+43-24
Original file line numberDiff line numberDiff line change
@@ -96,34 +96,53 @@ pub(crate) async fn build_details_handler(
9696
(output, Vec::new(), None)
9797
} else {
9898
let prefix = format!("build-logs/{}/", id);
99+
let all_log_filenames: Vec<_> = storage
100+
.list_prefix(&prefix) // the result from S3 is ordered by key
101+
.await
102+
.map_ok(|path| {
103+
path.strip_prefix(&prefix)
104+
.expect("since we query for the prefix, it has to be always there")
105+
.to_owned()
106+
})
107+
.try_collect()
108+
.await?;
109+
110+
let fetch_file = |filename: String| async {
111+
let file = File::from_path(&storage, &format!("{prefix}{filename}"), &config).await?;
112+
Ok::<_, anyhow::Error>(String::from_utf8(file.0.content).context("non utf8")?)
113+
};
99114

100-
if let Some(current_filename) = params
101-
.filename
102-
.or(row.default_target.map(|target| format!("{}.txt", target)))
103-
{
104-
let path = format!("{prefix}{current_filename}");
105-
let file = File::from_path(&storage, &path, &config).await?;
115+
let (filename, file_content) = if let Some(filename) = params.filename {
116+
(Some(filename.clone()), fetch_file(filename.clone()).await?)
117+
} else if let Some(default_target) = row.default_target {
118+
let filename = format!("{default_target}.txt");
106119
(
107-
String::from_utf8(file.0.content).context("non utf8")?,
108-
storage
109-
.list_prefix(&prefix) // the result from S3 is ordered by key
110-
.await
111-
.map_ok(|path| {
112-
path.strip_prefix(&prefix)
113-
.expect("since we query for the prefix, it has to be always there")
114-
.to_owned()
115-
})
116-
.try_collect()
117-
.await?,
118-
Some(current_filename),
120+
Some(filename),
121+
match fetch_file(filename.clone()).await {
122+
Ok(content) => content,
123+
Err(_err) => "".to_string(),
124+
},
119125
)
120126
} else {
121-
// this can only happen when `releases.default_target` is NULL,
122-
// which is the case for in-progress builds or builds which errored
123-
// before we could determine the target.
124-
// For the "error" case we show `row.errors`, which should contain what we need to see.
125-
("".into(), Vec::new(), None)
126-
}
127+
(None, "".into())
128+
};
129+
130+
// .or(row.default_target.map(|target| format!("{}.txt", target)))
131+
// {
132+
// let path = format!("{prefix}{current_filename}");
133+
// let file = File::from_path(&storage, &path, &config).await?;
134+
// (
135+
// String::from_utf8(file.0.content).context("non utf8")?,
136+
// Some(current_filename),
137+
// )
138+
// } else {
139+
// // this can only happen when `releases.default_target` is NULL,
140+
// // which is the case for in-progress builds or builds which errored
141+
// // before we could determine the target.
142+
// // For the "error" case we show `row.errors`, which should contain what we need to see.
143+
// ("".into(), Vec::new(), None)
144+
// }
145+
(file_content, all_log_filenames, filename)
127146
};
128147

129148
Ok(BuildDetailsPage {

0 commit comments

Comments
 (0)