Skip to content

Commit

Permalink
feat(artifacts): Update to zip 1.2 api
Browse files Browse the repository at this point in the history
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
  • Loading branch information
sjoerdsimons committed May 16, 2024
1 parent a7c4517 commit 7658277
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gitlab-runner/src/artifact.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Helpers for artifacts downloaded from gitlab
use std::{
io::{Read, Seek},
path::Path,
path::PathBuf,
};

use zip::{read::ZipFile, result::ZipResult};
Expand All @@ -21,7 +21,7 @@ impl ArtifactFile<'_> {
///
/// The path will be safe to use, that is to say it contains no NUL bytes and will be a
/// relative path that doesn't go outside of the root.
pub fn path(&self) -> Option<&Path> {
pub fn path(&self) -> Option<PathBuf> {
self.0.enclosed_name()
}
}
Expand Down
9 changes: 4 additions & 5 deletions gitlab-runner/src/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ enum UploadFileState<'a> {
),
}

fn zip_thread(mut temp: File, mut rx: mpsc::Receiver<UploadRequest>) {
let mut zip = zip::ZipWriter::new(&mut temp);
fn zip_thread(temp: File, mut rx: mpsc::Receiver<UploadRequest>) {
let mut zip = zip::ZipWriter::new(temp);
let options =
zip::write::FileOptions::default().compression_method(zip::CompressionMethod::Stored);
zip::write::SimpleFileOptions::default().compression_method(zip::CompressionMethod::Stored);

loop {
if let Some(request) = rx.blocking_recv() {
Expand All @@ -57,9 +57,8 @@ fn zip_thread(mut temp: File, mut rx: mpsc::Receiver<UploadRequest>) {
}
UploadRequest::Finish(tx) => {
let r = zip.finish();
drop(zip);
let reply = match r {
Ok(_) => temp.rewind().map(|()| temp),
Ok(mut file) => file.rewind().map(|()| file),
Err(e) => Err(std::io::Error::new(std::io::ErrorKind::Other, e)),
};
tx.send(reply).expect("Couldn't send finished zip");
Expand Down

0 comments on commit 7658277

Please sign in to comment.