File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed
Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ impl RepositoryManager {
8080 /// Before you can query plugin metadata from a repository, you need to call [RepositoryManager::check_for_updates].
8181 ///
8282 /// * `url` - URL to the plugins.json containing the records for this repository
83- /// * `repopath ` - path to where the repository will be stored on disk locally
83+ /// * `repository_path ` - path to where the repository will be stored on disk locally
8484 ///
8585 /// Returns true if the repository was successfully added, false otherwise.
8686 pub fn add_repository < U : BnStrCompatible , P : BnStrCompatible > (
@@ -99,15 +99,15 @@ impl RepositoryManager {
9999 }
100100 }
101101
102- pub fn repository_by_path < P : BnStrCompatible > ( & self , path : P ) -> Repository {
102+ pub fn repository_by_path < P : BnStrCompatible > ( & self , path : P ) -> Option < Repository > {
103103 let path = path. into_bytes_with_nul ( ) ;
104104 let result = unsafe {
105105 BNRepositoryGetRepositoryByPath (
106106 self . as_raw ( ) ,
107107 path. as_ref ( ) . as_ptr ( ) as * const ffi:: c_char ,
108108 )
109109 } ;
110- unsafe { Repository :: from_raw ( ptr:: NonNull :: new ( result) . unwrap ( ) ) }
110+ ptr:: NonNull :: new ( result) . map ( |raw| unsafe { Repository :: from_raw ( raw ) } )
111111 }
112112
113113 /// Gets the default Repository
Original file line number Diff line number Diff line change 1+ use binaryninja:: headless:: Session ;
2+ use binaryninja:: repository:: RepositoryManager ;
3+ use rstest:: * ;
4+
5+ #[ fixture]
6+ fn session ( ) -> Session {
7+ Session :: new ( ) . expect ( "Failed to initialize session" )
8+ }
9+
10+ #[ rstest]
11+ fn test_list ( _session : Session ) {
12+ let manager = RepositoryManager :: default ( ) ;
13+ let repositories = manager. repositories ( ) ;
14+ for repository in & repositories {
15+ let repo_path = repository. path ( ) ;
16+ let repository_by_path = manager. repository_by_path ( repo_path) . unwrap ( ) ;
17+ assert_eq ! ( repository. url( ) , repository_by_path. url( ) ) ;
18+ }
19+
20+ let repository = manager. default_repository ( ) ;
21+ let _full_path = repository. full_path ( ) ;
22+ let _path = repository. path ( ) ;
23+ let _url = repository. url ( ) ;
24+ let plugins = repository. plugins ( ) ;
25+ for plugin in & plugins {
26+ let plugin_path = plugin. path ( ) ;
27+ let plugin_by_path = repository. plugin_by_path ( plugin_path) . unwrap ( ) ;
28+ assert_eq ! ( plugin. package_url( ) , plugin_by_path. package_url( ) ) ;
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments