@@ -299,10 +299,17 @@ static void onDirResponse(const net_get_data* netData)
299299 string url ;
300300 if (json_tostring (json_array_item (files , i ), url , sizeof url ))
301301 {
302- char * base = strrchr (url , '/' );
302+ const char * base = strrchr (url , '/' );
303303 if (base )
304304 {
305- netDirData -> item (base + 1 , base + 1 , url , 0 , netDirData -> data , false);
305+ string name ;
306+ const char * hash = strrchr (url , '?' );
307+
308+ if (hash )
309+ {
310+ snprintf (name , hash - base , "%s" , base + 1 );
311+ netDirData -> item (name , NULL , url , 0 , netDirData -> data , false);
312+ }
306313 }
307314 }
308315 }
@@ -762,7 +769,7 @@ typedef struct
762769 tic_fs * fs ;
763770 fs_load_callback done ;
764771 void * data ;
765- char * cachePath ;
772+ char cachePath [ TICNAME_MAX ] ;
766773} LoadFileByHashData ;
767774
768775static void fileByHashLoaded (const net_get_data * netData )
@@ -780,7 +787,6 @@ static void fileByHashLoaded(const net_get_data* netData)
780787 case net_get_done :
781788 case net_get_error :
782789
783- free (loadFileByHashData -> cachePath );
784790 free (loadFileByHashData );
785791 break ;
786792 default : break ;
@@ -794,25 +800,30 @@ void tic_fs_hashload(tic_fs* fs, const char* name, const char* url, fs_load_call
794800 return ;
795801#else
796802
797- char cachePath [TICNAME_MAX ];
798- const char * hash = md5str (url , strlen (url ));
799- snprintf (cachePath , sizeof cachePath , TIC_CACHE "%s.tic" , hash );
803+ #if defined(BUILD_EDITORS )
804+ LoadFileByHashData loadFileByHashData = { fs , callback , data };
800805
806+ const char * hash = strrchr (url , '?' );
807+
808+ if (hash )
801809 {
802- s32 size = 0 ;
803- void * buffer = tic_fs_loadroot (fs , cachePath , & size );
804- if (buffer )
810+ snprintf (loadFileByHashData .cachePath , sizeof loadFileByHashData .cachePath , TIC_CACHE "%s.tic" , hash + 1 );
811+
805812 {
806- callback (buffer , size , data );
807- free (buffer );
808- return ;
813+ s32 size = 0 ;
814+ void * buffer = tic_fs_loadroot (fs , loadFileByHashData .cachePath , & size );
815+ if (buffer )
816+ {
817+ callback (buffer , size , data );
818+ free (buffer );
819+ return ;
820+ }
809821 }
810- }
811822
812- #if defined(BUILD_EDITORS )
813823
814- LoadFileByHashData loadFileByHashData = { fs , callback , data , strdup (cachePath ) };
815- tic_net_get (fs -> net , url , fileByHashLoaded , MOVE (loadFileByHashData ));
824+ tic_net_get (fs -> net , url , fileByHashLoaded , MOVE (loadFileByHashData ));
825+ }
826+
816827#endif
817828
818829#endif
0 commit comments