@@ -191,14 +191,11 @@ impl DataType for Image {
191191 . map_err ( |e| StoreEntryError :: new ( source_root. to_path_buf ( ) , e. into ( ) ) ) ?;
192192
193193 for ( entry_name, is_dir) in entries {
194- let full_rel = source_root. join ( & entry_name) ;
195194 if is_dir {
196195 // The spec forbids directories.
197- return Err ( StoreEntryError :: new ( full_rel, StoreError :: Subdir ) ) ;
198- } else {
199- let key = full_rel. strip_prefix ( source_root) . unwrap ( ) . to_path_buf ( ) ;
200- paths. push ( key) ;
196+ return Err ( StoreEntryError :: new ( entry_name, StoreError :: Subdir ) ) ;
201197 }
198+ paths. push ( entry_name) ;
202199 }
203200
204201 Ok ( paths)
@@ -806,16 +803,13 @@ mod tests {
806803
807804 /// A FontSource backed by in-memory data, with `as_path() -> None`.
808805 /// This triggers the eager-loading branch in `Store::new`.
806+ #[ derive( Default ) ]
809807 struct MemorySource {
810808 files : HashMap < PathBuf , Vec < u8 > > ,
811809 dirs : HashMap < PathBuf , Vec < ( PathBuf , bool ) > > ,
812810 }
813811
814812 impl MemorySource {
815- fn new ( ) -> Self {
816- MemorySource { files : HashMap :: new ( ) , dirs : HashMap :: new ( ) }
817- }
818-
819813 fn add_file ( & mut self , path : impl Into < PathBuf > , data : Vec < u8 > ) {
820814 self . files . insert ( path. into ( ) , data) ;
821815 }
@@ -841,7 +835,7 @@ mod tests {
841835
842836 #[ test]
843837 fn data_eager_loading_from_memory_source ( ) {
844- let mut source = MemorySource :: new ( ) ;
838+ let mut source = MemorySource :: default ( ) ;
845839 source. add_dir (
846840 "data" ,
847841 vec ! [ ( PathBuf :: from( "a.txt" ) , false ) , ( PathBuf :: from( "b.txt" ) , false ) ] ,
@@ -865,7 +859,7 @@ mod tests {
865859 #[ test]
866860 fn image_eager_loading_from_memory_source ( ) {
867861 let img = png_data ( b"test" ) ;
868- let mut source = MemorySource :: new ( ) ;
862+ let mut source = MemorySource :: default ( ) ;
869863 source. add_dir ( "images" , vec ! [ ( PathBuf :: from( "x.png" ) , false ) ] ) ;
870864 source. add_file ( "images/x.png" , img. clone ( ) ) ;
871865
@@ -879,7 +873,7 @@ mod tests {
879873
880874 #[ test]
881875 fn eager_load_invalid_image_fails_at_construction ( ) {
882- let mut source = MemorySource :: new ( ) ;
876+ let mut source = MemorySource :: default ( ) ;
883877 source. add_dir ( "images" , vec ! [ ( PathBuf :: from( "bad.png" ) , false ) ] ) ;
884878 source. add_file ( "images/bad.png" , b"not a png" . to_vec ( ) ) ;
885879
@@ -890,7 +884,7 @@ mod tests {
890884
891885 #[ test]
892886 fn eager_load_nested_data_from_memory_source ( ) {
893- let mut source = MemorySource :: new ( ) ;
887+ let mut source = MemorySource :: default ( ) ;
894888 source
895889 . add_dir ( "data" , vec ! [ ( PathBuf :: from( "top.txt" ) , false ) , ( PathBuf :: from( "sub" ) , true ) ] ) ;
896890 source. add_dir ( "data/sub" , vec ! [ ( PathBuf :: from( "deep.txt" ) , false ) ] ) ;
0 commit comments