@@ -7,7 +7,7 @@ use async_trait::async_trait;
77use slog:: Logger ;
88
99use crate :: data:: subgraph:: Link ;
10- use crate :: prelude:: { DeploymentHash , Error , JsonValueStream , LinkResolver as LinkResolverTrait } ;
10+ use crate :: prelude:: { Error , JsonValueStream , LinkResolver as LinkResolverTrait } ;
1111
1212#[ derive( Clone , Debug ) ]
1313pub struct FileLinkResolver {
@@ -70,20 +70,19 @@ impl FileLinkResolver {
7070 /// It will set the base directory to the parent directory of the manifest path
7171 /// This is required because paths mentioned in the subgraph manifest are relative paths
7272 /// and we need a new resolver with the right base directory for the specific subgraph
73- fn clone_for_deployment ( & self , deployment : DeploymentHash ) -> Result < Self , Error > {
73+ fn clone_for_manifest ( & self , manifest_path_str : & str ) -> Result < Self , Error > {
7474 let mut resolver = self . clone ( ) ;
7575
76- let deployment_str = deployment. to_string ( ) ;
77-
7876 // Create a path to the manifest based on the current resolver's
7977 // base directory or default to using the deployment string as path
8078 // If the deployment string is an alias, use the aliased path
81- let manifest_path = if let Some ( aliased) = self . aliases . get ( & deployment_str) {
79+ let manifest_path = if let Some ( aliased) = self . aliases . get ( & manifest_path_str. to_string ( ) )
80+ {
8281 aliased. clone ( )
8382 } else {
8483 match & resolver. base_dir {
85- Some ( dir) => dir. join ( & deployment_str ) ,
86- None => PathBuf :: from ( deployment_str ) ,
84+ Some ( dir) => dir. join ( & manifest_path_str ) ,
85+ None => PathBuf :: from ( manifest_path_str ) ,
8786 }
8887 } ;
8988
@@ -142,11 +141,8 @@ impl LinkResolverTrait for FileLinkResolver {
142141 }
143142 }
144143
145- fn for_deployment (
146- & self ,
147- deployment : DeploymentHash ,
148- ) -> Result < Box < dyn LinkResolverTrait > , Error > {
149- Ok ( Box :: new ( self . clone_for_deployment ( deployment) ?) )
144+ fn for_manifest ( & self , manifest_path : & str ) -> Result < Box < dyn LinkResolverTrait > , Error > {
145+ Ok ( Box :: new ( self . clone_for_manifest ( manifest_path) ?) )
150146 }
151147
152148 async fn get_block ( & self , _logger : & Logger , _link : & Link ) -> Result < Vec < u8 > , Error > {
@@ -290,8 +286,7 @@ mod tests {
290286 assert_eq ! ( result2, test_content2) ;
291287
292288 // Test that the alias works in for_deployment as well
293- let deployment = DeploymentHash :: new ( "deployment-id" ) . unwrap ( ) ;
294- let deployment_resolver = resolver. clone_for_deployment ( deployment) . unwrap ( ) ;
289+ let deployment_resolver = resolver. clone_for_manifest ( "deployment-id" ) . unwrap ( ) ;
295290
296291 let expected_dir = test_file1_path. parent ( ) . unwrap ( ) ;
297292 let deployment_base_dir = deployment_resolver. base_dir . clone ( ) . unwrap ( ) ;
0 commit comments