File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ impl BuildStamp {
3434 ///
3535 /// By default, stamp will be an empty file named `.stamp` within the specified directory.
3636 pub fn new ( dir : & Path ) -> Self {
37+ // Avoid using `is_dir()` as the directory may not exist yet.
38+ // It is more appropriate to assert that the path is not a file.
39+ assert ! ( !dir. is_file( ) , "can't be a file path" ) ;
3740 Self { path : dir. join ( ".stamp" ) , stamp : String :: new ( ) }
3841 }
3942
@@ -52,7 +55,7 @@ impl BuildStamp {
5255 "prefix can not start or end with '.'"
5356 ) ;
5457
55- let stamp_filename = self . path . components ( ) . last ( ) . unwrap ( ) . as_os_str ( ) . to_str ( ) . unwrap ( ) ;
58+ let stamp_filename = self . path . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
5659 let stamp_filename = stamp_filename. strip_prefix ( '.' ) . unwrap_or ( stamp_filename) ;
5760 self . path . set_file_name ( format ! ( ".{prefix}-{stamp_filename}" ) ) ;
5861
You can’t perform that action at this time.
0 commit comments