@@ -51,6 +51,7 @@ use std::num::NonZeroU64;
51
51
use std:: sync:: Arc ;
52
52
use tokio:: io:: AsyncReadExt ;
53
53
use tokio:: io:: AsyncSeekExt ;
54
+ use tokio:: io:: AsyncWriteExt ;
54
55
use tokio:: io:: SeekFrom ;
55
56
use tufaceous_artifact:: ArtifactHash ;
56
57
use zip:: ZipArchive ;
@@ -983,29 +984,30 @@ async fn save_zone_log_zip_or_error(
983
984
Ok ( res) => {
984
985
let bytestream = res. into_inner ( ) ;
985
986
let output_dir = path. join ( format ! ( "logs/{zone}" ) ) ;
986
- let output_file = output_dir. join ( "logs.zip" ) ;
987
+ let output_path = output_dir. join ( "logs.zip" ) ;
987
988
988
989
// Ensure the logs output directory exists.
989
990
tokio:: fs:: create_dir_all ( & output_dir) . await . with_context (
990
991
|| format ! ( "failed to create output directory: {output_dir}" ) ,
991
992
) ?;
992
993
993
994
let mut file =
994
- tokio:: fs:: File :: create ( & output_file ) . await . with_context (
995
- || format ! ( "failed to create file: {output_file }" ) ,
995
+ tokio:: fs:: File :: create ( & output_path ) . await . with_context (
996
+ || format ! ( "failed to create file: {output_path }" ) ,
996
997
) ?;
997
998
998
999
let stream = bytestream. into_inner ( ) . map ( |chunk| {
999
1000
chunk. map_err ( |e| std:: io:: Error :: other ( e. to_string ( ) ) )
1000
1001
} ) ;
1001
1002
let mut reader = tokio_util:: io:: StreamReader :: new ( stream) ;
1002
1003
let _nbytes = tokio:: io:: copy ( & mut reader, & mut file) . await ?;
1004
+ file. flush ( ) . await ?;
1003
1005
1004
1006
// Unpack the zip so we don't end up with zip files inside of our
1005
1007
// final zip
1006
- let zipfile = output_file . clone ( ) ;
1008
+ let zipfile_path = output_path . clone ( ) ;
1007
1009
tokio:: task:: spawn_blocking ( move || {
1008
- extract_zip_file ( & output_dir, & zipfile )
1010
+ extract_zip_file ( & output_dir, & zipfile_path )
1009
1011
} )
1010
1012
. await
1011
1013
. map_err ( |join_error| {
@@ -1014,12 +1016,12 @@ async fn save_zone_log_zip_or_error(
1014
1016
} ) ??;
1015
1017
1016
1018
// Cleanup the zip file since we no longer need it
1017
- if let Err ( e) = tokio:: fs:: remove_file ( & output_file ) . await {
1019
+ if let Err ( e) = tokio:: fs:: remove_file ( & output_path ) . await {
1018
1020
error ! (
1019
1021
logger,
1020
1022
"failed to cleanup temporary logs zip file" ;
1021
1023
"error" => %e,
1022
- "file" => %output_file ,
1024
+ "file" => %output_path ,
1023
1025
1024
1026
) ;
1025
1027
}
0 commit comments