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 {
34
34
///
35
35
/// By default, stamp will be an empty file named `.stamp` within the specified directory.
36
36
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" ) ;
37
40
Self { path : dir. join ( ".stamp" ) , stamp : String :: new ( ) }
38
41
}
39
42
@@ -52,7 +55,7 @@ impl BuildStamp {
52
55
"prefix can not start or end with '.'"
53
56
) ;
54
57
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 ( ) ;
56
59
let stamp_filename = stamp_filename. strip_prefix ( '.' ) . unwrap_or ( stamp_filename) ;
57
60
self . path . set_file_name ( format ! ( ".{prefix}-{stamp_filename}" ) ) ;
58
61
You can’t perform that action at this time.
0 commit comments