File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
use std:: collections:: HashMap ;
2
- use std:: fs:: { self , File , OpenOptions } ;
2
+ use std:: fs:: { self , OpenOptions } ;
3
3
use std:: io:: prelude:: * ;
4
4
use std:: path:: { Path , PathBuf } ;
5
5
@@ -409,10 +409,15 @@ pub fn squash_index(env: &Environment) -> Result<(), PerformError> {
409
409
_ => return Err ( String :: from ( "squash_index: Could not determine credentials" ) . into ( ) ) ,
410
410
} ;
411
411
412
- let temp_key_file = tempfile:: Builder :: new ( ) . tempfile ( ) ?;
413
- let mut file = File :: create ( & temp_key_file) ?;
414
- file. write_all ( key. as_bytes ( ) ) ?;
415
- drop ( file) ;
412
+ // When running on production, ensure the file is created in tmpfs and not persisted to disk
413
+ #[ cfg( target_os = "linux" ) ]
414
+ let mut temp_key_file = tempfile:: Builder :: new ( ) . tempfile_in ( "/dev/shm" ) ?;
415
+
416
+ // For other platforms, default to std::env::tempdir()
417
+ #[ cfg( not( target_os = "linux" ) ) ]
418
+ let mut temp_key_file = tempfile:: Builder :: new ( ) . tempfile ( ) ?;
419
+
420
+ temp_key_file. write_all ( key. as_bytes ( ) ) ?;
416
421
417
422
let checkout_path = repo. checkout_path . path ( ) ;
418
423
let output = std:: process:: Command :: new ( "git" )
You can’t perform that action at this time.
0 commit comments