@@ -67,7 +67,7 @@ pub struct Hub {
6767 /// GitHub repository owner
6868 owner : String ,
6969
70- /// GitHub repository name
70+ /// GitHub repository name
7171 repo : String ,
7272
7373 /// Directory to store the downloaded file
@@ -151,6 +151,10 @@ impl Hub {
151151 anyhow:: bail!( "HF hub support is not enabled. Please enable the 'hf-hub' feature." )
152152 }
153153
154+ pub fn try_fetch ( & mut self , s : & str ) -> Result < String > {
155+ unimplemented ! ( "'http' feature not enabled, ureq compiled out" )
156+ }
157+
154158 /// Attempts to fetch a file from a local path, GitHub release, or Hugging Face repository.
155159 ///
156160 /// The `try_fetch` method supports multiple scenarios:
@@ -199,6 +203,7 @@ impl Hub {
199203 /// let temp_hf_path = Hub::default().try_fetch("BAAI/bge-m3/sentencepiece.bpe.model")
200204 /// .expect("Failed to fetch HF file");
201205 /// ```
206+ #[ cfg( feature = "http" ) ]
202207 pub fn try_fetch ( & mut self , s : & str ) -> Result < String > {
203208 #[ derive( Default , Debug , aksr:: Builder ) ]
204209 struct Pack {
@@ -405,7 +410,13 @@ impl Hub {
405410 . with_context ( || format ! ( "Failed to convert PathBuf: {:?} to String" , saveout) )
406411 }
407412
413+ #[ cfg( not( feature = "http" ) ) ]
414+ fn fetch_and_cache_releases ( & self , url : & str , cache_path : & Path ) -> Result < String > {
415+ unimplemented ! ( "'http' feature not enabled, ureq compiled out" )
416+ }
417+
408418 /// Fetch releases from GitHub and cache them
419+ #[ cfg( feature = "http" ) ]
409420 fn fetch_and_cache_releases ( & self , url : & str , cache_path : & Path ) -> Result < String > {
410421 let response = retry ! ( self . max_attempts, self . fetch_get_response( url) ) ?;
411422 let body = response
@@ -479,7 +490,18 @@ impl Hub {
479490 Ok ( y)
480491 }
481492
493+ #[ cfg( not( feature = "http" ) ) ]
494+ pub fn download < P : AsRef < Path > + std:: fmt:: Debug > (
495+ & self ,
496+ src : & str ,
497+ dst : P ,
498+ message : Option < & str > ,
499+ ) -> Result < ( ) > {
500+ unimplemented ! ( "'http' feature disabled, ureq compiled out" )
501+ }
502+
482503 /// Download a file from a github release to a specified path with a progress bar
504+ #[ cfg( feature = "http" ) ]
483505 pub fn download < P : AsRef < Path > + std:: fmt:: Debug > (
484506 & self ,
485507 src : & str ,
@@ -558,6 +580,7 @@ impl Hub {
558580 Ok ( ( ) )
559581 }
560582
583+ #[ cfg( feature = "http" ) ]
561584 fn fetch_get_response ( & self , url : & str ) -> anyhow:: Result < http:: Response < ureq:: Body > > {
562585 let config = ureq:: Agent :: config_builder ( )
563586 . proxy ( ureq:: Proxy :: try_from_env ( ) )
0 commit comments