@@ -4,7 +4,7 @@ use std::{
4
4
fs:: File ,
5
5
hash:: { Hash , Hasher } ,
6
6
io:: SeekFrom ,
7
- path:: PathBuf ,
7
+ path:: { Path , PathBuf } ,
8
8
} ;
9
9
10
10
use async_trait:: async_trait;
@@ -19,7 +19,6 @@ use gitlab_runner::{
19
19
} ;
20
20
use open_build_service_api as obs;
21
21
use serde:: { Deserialize , Serialize } ;
22
- use tempfile:: NamedTempFile ;
23
22
use tokio:: { fs:: File as AsyncFile , io:: AsyncSeekExt } ;
24
23
use tokio_util:: { compat:: TokioAsyncReadCompatExt , io:: ReaderStream } ;
25
24
use tracing:: { debug, error, instrument, warn} ;
@@ -242,9 +241,12 @@ impl UploadableFile for ObsArtifact {
242
241
243
242
impl ObsBuildInfo {
244
243
#[ instrument]
245
- fn save ( & self ) -> Result < PathBuf > {
246
- let mut temp_file =
247
- NamedTempFile :: new ( ) . wrap_err ( "Failed to create file for build info" ) ?;
244
+ fn save ( & self , dir : & Path ) -> Result < PathBuf > {
245
+ let mut temp_file = tempfile:: Builder :: new ( )
246
+ . prefix ( "obs-glr-build-info-" )
247
+ . suffix ( ".yml" )
248
+ . tempfile_in ( dir)
249
+ . wrap_err ( "Failed to create file for build info" ) ?;
248
250
serde_yaml:: to_writer ( temp_file. as_file_mut ( ) , self )
249
251
. wrap_err ( "Failed to write build yaml to file" ) ?;
250
252
let ( _file, path) = temp_file
@@ -373,7 +375,10 @@ impl ObsJobHandler {
373
375
debug ! ( "Saving initial build info: {:?}" , build_info) ;
374
376
375
377
let build_info_2 = build_info. clone ( ) ;
376
- let build_info_path = tokio:: task:: spawn_blocking ( move || build_info_2. save ( ) ) . await ??;
378
+ let build_info_path = {
379
+ let build_dir = self . job . build_dir ( ) . to_owned ( ) ;
380
+ tokio:: task:: spawn_blocking ( move || build_info_2. save ( & build_dir) ) . await ??
381
+ } ;
377
382
378
383
self . artifacts . replace ( ObsArtifact :: new_file (
379
384
args. build_info_out . clone ( ) ,
@@ -454,7 +459,10 @@ impl ObsJobHandler {
454
459
} ;
455
460
debug ! ( "Saving complete build info: {:?}" , build_info) ;
456
461
457
- let build_info_path = tokio:: task:: spawn_blocking ( move || build_info. save ( ) ) . await ??;
462
+ let build_info_path = {
463
+ let build_dir = self . job . build_dir ( ) . to_owned ( ) ;
464
+ tokio:: task:: spawn_blocking ( move || build_info. save ( & build_dir) ) . await ??
465
+ } ;
458
466
self . artifacts
459
467
. replace ( ObsArtifact :: new_file ( args. build_info_out , build_info_path) ) ;
460
468
@@ -524,7 +532,7 @@ impl ObsJobHandler {
524
532
. await ?;
525
533
debug ! ( "Completed with: {:?}" , completion) ;
526
534
527
- let log_file = monitor. download_build_log ( ) . await ?;
535
+ let log_file = monitor. download_build_log ( self . job . build_dir ( ) ) . await ?;
528
536
self . artifacts . replace ( ObsArtifact :: new_file (
529
537
args. build_log_out . clone ( ) ,
530
538
log_file. path . clone ( ) ,
@@ -575,6 +583,7 @@ impl ObsJobHandler {
575
583
async fn run_download_binaries ( & mut self , args : DownloadBinariesAction ) -> Result < ( ) > {
576
584
let binaries = download_binaries (
577
585
self . client . clone ( ) ,
586
+ self . job . build_dir ( ) ,
578
587
& args. project ,
579
588
& args. package ,
580
589
& args. repository ,
0 commit comments