11// don't warn about try_from paths conversion on unix
22#![ allow( clippy:: unnecessary_fallible_conversions) ]
33
4- use std:: {
5- path:: { Path , PathBuf } ,
6- str:: FromStr ,
7- } ;
4+ use std:: { path:: PathBuf , str:: FromStr } ;
85
96use anyhow:: Result ;
107use globset:: Glob ;
@@ -13,6 +10,7 @@ use rstest::rstest;
1310
1411use rustic_core:: {
1512 repofile:: { Node , SnapshotFile } ,
13+ util:: GlobMatcherExt ,
1614 BackupOptions , FindMatches , FindNode ,
1715} ;
1816use typed_path:: UnixPath ;
@@ -39,9 +37,8 @@ fn test_find(tar_gz_testdata: Result<TestSource>, set_up_repo: Result<RepoOpen>)
3937 assert_with_win ( "find-nodes-not-found" , not_found) ;
4038 // test non-existing match
4139 let glob = Glob :: new ( "not_existing" ) ?. compile_matcher ( ) ;
42- let not_found = repo. find_matching_nodes ( vec ! [ snapshot. tree] , & |path, _| {
43- glob. is_match ( PathBuf :: try_from ( path) . unwrap ( ) )
44- } ) ?;
40+ let not_found =
41+ repo. find_matching_nodes ( vec ! [ snapshot. tree] , & |path, _| glob. is_unix_match ( path) ) ?;
4542 assert_debug_snapshot ! ( "find-matching-nodes-not-found" , not_found) ;
4643
4744 // test existing path
@@ -51,21 +48,15 @@ fn test_find(tar_gz_testdata: Result<TestSource>, set_up_repo: Result<RepoOpen>)
5148 // test existing match
5249 let glob = Glob :: new ( "testfile" ) ?. compile_matcher ( ) ;
5350 let match_func = |path : & UnixPath , _: & Node | {
54- glob. is_match ( PathBuf :: try_from ( path) . unwrap ( ) )
55- || path
56- . file_name ( )
57- . is_some_and ( |f| glob. is_match ( Path :: new ( & String :: from_utf8 ( f. to_vec ( ) ) . unwrap ( ) ) ) )
51+ glob. is_unix_match ( path) || path. file_name ( ) . is_some_and ( |f| glob. is_unix_match ( f) )
5852 } ;
5953 let FindMatches { paths, matches, .. } =
6054 repo. find_matching_nodes ( vec ! [ snapshot. tree] , & match_func) ?;
6155 assert_debug_snapshot ! ( "find-matching-existing" , ( paths, matches) ) ;
6256 // test existing match
6357 let glob = Glob :: new ( "testfile*" ) ?. compile_matcher ( ) ;
6458 let match_func = |path : & UnixPath , _: & Node | {
65- glob. is_match ( PathBuf :: try_from ( path) . unwrap ( ) )
66- || path
67- . file_name ( )
68- . is_some_and ( |f| glob. is_match ( Path :: new ( & String :: from_utf8 ( f. to_vec ( ) ) . unwrap ( ) ) ) )
59+ glob. is_unix_match ( path) || path. file_name ( ) . is_some_and ( |f| glob. is_unix_match ( f) )
6960 } ;
7061 let FindMatches { paths, matches, .. } =
7162 repo. find_matching_nodes ( vec ! [ snapshot. tree] , & match_func) ?;
0 commit comments