Skip to content

Commit

Permalink
Merge pull request #83 from traP-jp/feat/#82-onetime-text-is-readonly
Browse files Browse the repository at this point in the history
🐛 onetime text is readonly
  • Loading branch information
comavius authored Dec 22, 2024
2 parents b5d8da3 + 5160c4e commit b337bc9
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/submission_logic/file_preparation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@ pub async fn prepare_files<
Ok((name, file))
})
.collect::<Result<HashMap<_, _>>>()?;
let one_time_text_files = onetime_text_files
let one_time_text_files =
futures::future::join_all(onetime_text_files.into_iter().enumerate().map(
|(i, writable_file)| async move {
let name = format!("ONETIME_TEXT_{}", i).to_string();
let readonly = writable_file
.with_context(|| format!("Failed to create onetime text file {}", i))?
.to_readonly()
.await
.with_context(|| format!("Failed to convert onetime text file {}", i))?;
Ok((name, readonly))
},
))
.await
.into_iter()
.enumerate()
.map(|(i, file)| {
let name = format!("ONETIME_TEXT_{}", i).to_string();
let file = file.with_context(|| format!("Failed to create onetime text file {}", i))?;
Ok((name, file))
})
.collect::<Result<HashMap<_, _>>>()?;
let directories = directories
.into_iter()
Expand All @@ -64,8 +70,8 @@ pub async fn prepare_files<
let shellhook = shellhook.with_context(|| "Failed to create shellhook")?;

let mut all_readonly_files = text_files;
let mut all_writable_files = one_time_text_files;
all_writable_files.extend(directories);
let all_writable_files = directories;
all_readonly_files.extend(one_time_text_files);
all_readonly_files.insert("SHELLHOOK".to_string(), shellhook);

// set uuids
Expand Down

0 comments on commit b337bc9

Please sign in to comment.