@@ -335,8 +335,11 @@ pub(crate) fn write_metadata(staging: &Path, fingerprint: &str, artifacts: &[&st
335335/// Publish a fully validated staging directory by one same-filesystem rename.
336336/// A key is never observable as successful until every artifact and its
337337/// metadata are complete.
338- pub ( crate ) fn publish_staging ( staging : tempfile:: TempDir , target : & Path ) -> Result < ( ) > {
339- let staging_path = staging. keep ( ) ;
338+ pub ( crate ) fn publish_staging (
339+ staging : kernal_api:: platform:: fs:: TemporaryDirectory ,
340+ target : & Path ,
341+ ) -> Result < ( ) > {
342+ let staging_path = staging. persist ( ) ;
340343 if target. exists ( ) {
341344 fs:: remove_dir_all ( target)
342345 . with_context ( || format ! ( "remove invalid cache entry {}" , target. display( ) ) ) ?;
@@ -354,12 +357,13 @@ pub(crate) fn publish_staging(staging: tempfile::TempDir, target: &Path) -> Resu
354357 Ok ( ( ) )
355358}
356359
357- pub ( crate ) fn staging_dir ( cache_root : & Path , prefix : & str ) -> Result < tempfile:: TempDir > {
360+ pub ( crate ) fn staging_dir (
361+ cache_root : & Path ,
362+ prefix : & str ,
363+ ) -> Result < kernal_api:: platform:: fs:: TemporaryDirectory > {
358364 fs:: create_dir_all ( cache_root)
359365 . with_context ( || format ! ( "create cache root {}" , cache_root. display( ) ) ) ?;
360- tempfile:: Builder :: new ( )
361- . prefix ( prefix)
362- . tempdir_in ( cache_root)
366+ kernal_api:: platform:: fs:: TemporaryDirectory :: in_directory ( cache_root, prefix)
363367 . with_context ( || format ! ( "create staging directory in {}" , cache_root. display( ) ) )
364368}
365369
@@ -473,7 +477,7 @@ mod tests {
473477 // the persistent fingerprint before the next lookup.
474478 #[ test]
475479 fn explicit_invalidation_detects_immediate_same_size_edit_with_restored_mtime ( ) {
476- let temp = tempfile :: tempdir ( ) . unwrap ( ) ;
480+ let temp = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
477481 let source = temp. path ( ) . join ( "sketch.ino" ) ;
478482 fs:: write ( & source, "aaaa" ) . unwrap ( ) ;
479483 let mut fingerprint = fingerprint_tree_persistent ( temp. path ( ) , & [ "**/*.ino" ] , & [ ] ) . unwrap ( ) ;
@@ -499,8 +503,8 @@ mod tests {
499503
500504 #[ test]
501505 fn path_invalidation_dirties_only_matching_spec ( ) {
502- let first = tempfile :: tempdir ( ) . unwrap ( ) ;
503- let second = tempfile :: tempdir ( ) . unwrap ( ) ;
506+ let first = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
507+ let second = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
504508 fs:: write ( first. path ( ) . join ( "one.cpp" ) , "one" ) . unwrap ( ) ;
505509 fs:: write ( second. path ( ) . join ( "two.cpp" ) , "two" ) . unwrap ( ) ;
506510 fingerprint_tree_persistent ( first. path ( ) , & [ "**/*.cpp" ] , & [ ] ) . unwrap ( ) ;
@@ -516,7 +520,7 @@ mod tests {
516520
517521 #[ test]
518522 fn lost_fingerprint_watch_discards_cached_value_and_registers_again ( ) {
519- let temp = tempfile :: tempdir ( ) . unwrap ( ) ;
523+ let temp = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
520524 fs:: write ( temp. path ( ) . join ( "sketch.ino" ) , "aaaa" ) . unwrap ( ) ;
521525 let expected = fingerprint_tree_persistent ( temp. path ( ) , & [ "**/*.ino" ] , & [ ] ) . unwrap ( ) ;
522526 let spec = FingerprintSpec {
@@ -542,8 +546,8 @@ mod tests {
542546
543547 #[ test]
544548 fn invalidate_all_dirties_every_spec ( ) {
545- let first = tempfile :: tempdir ( ) . unwrap ( ) ;
546- let second = tempfile :: tempdir ( ) . unwrap ( ) ;
549+ let first = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
550+ let second = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
547551 fs:: write ( first. path ( ) . join ( "one.cpp" ) , "one" ) . unwrap ( ) ;
548552 fs:: write ( second. path ( ) . join ( "two.cpp" ) , "two" ) . unwrap ( ) ;
549553 fingerprint_tree_persistent ( first. path ( ) , & [ "**/*.cpp" ] , & [ ] ) . unwrap ( ) ;
@@ -554,7 +558,7 @@ mod tests {
554558
555559 #[ test]
556560 fn excluded_output_path_does_not_dirty_spec ( ) {
557- let temp = tempfile :: tempdir ( ) . unwrap ( ) ;
561+ let temp = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
558562 fs:: create_dir_all ( temp. path ( ) . join ( "fastled_js" ) ) . unwrap ( ) ;
559563 fs:: write ( temp. path ( ) . join ( "source.cpp" ) , "source" ) . unwrap ( ) ;
560564 fingerprint_tree_persistent ( temp. path ( ) , & [ "**/*.cpp" ] , & [ "fastled_js/**" ] ) . unwrap ( ) ;
@@ -588,7 +592,7 @@ mod tests {
588592
589593 #[ test]
590594 fn validation_rejects_missing_empty_truncated_and_corrupt_entries ( ) {
591- let temp = tempfile :: tempdir ( ) . unwrap ( ) ;
595+ let temp = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
592596 let entry = temp. path ( ) . join ( "entry" ) ;
593597 fs:: create_dir ( & entry) . unwrap ( ) ;
594598 fs:: write ( entry. join ( "fastled.js" ) , "js" ) . unwrap ( ) ;
@@ -612,7 +616,7 @@ mod tests {
612616
613617 #[ test]
614618 fn cache_lock_serializes_same_key ( ) {
615- let temp = tempfile :: tempdir ( ) . unwrap ( ) ;
619+ let temp = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
616620 let root = temp. path ( ) . to_path_buf ( ) ;
617621 let barrier = Arc :: new ( Barrier :: new ( 2 ) ) ;
618622 let other_barrier = Arc :: clone ( & barrier) ;
@@ -630,7 +634,7 @@ mod tests {
630634
631635 #[ test]
632636 fn atomic_publish_replaces_invalid_entry ( ) {
633- let temp = tempfile :: tempdir ( ) . unwrap ( ) ;
637+ let temp = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
634638 let root = temp. path ( ) . join ( "cache" ) ;
635639 fs:: create_dir ( & root) . unwrap ( ) ;
636640 let target = root. join ( "key" ) ;
@@ -648,7 +652,7 @@ mod tests {
648652
649653 #[ test]
650654 fn attempt_state_records_pending_failure_and_clears_after_success ( ) {
651- let temp = tempfile :: tempdir ( ) . unwrap ( ) ;
655+ let temp = kernal_api :: platform :: fs :: TemporaryDirectory :: new ( ) . unwrap ( ) ;
652656 mark_pending ( temp. path ( ) , "key" , "main-link" ) . unwrap ( ) ;
653657 assert_eq ! (
654658 previous_attempt( temp. path( ) , "key" ) . as_deref( ) ,
0 commit comments