WWW.LoadFromCacheOrDownload(string url, Hash128 hash) strange behaviour

Hi!

I have problem with method WWW.LoadFromCacheOrDownload(string url, Hash128 hash). For example this code:

Hash128 hash = Hash128.Parse("any_string");
Debug.Log(Caching.IsVersionCached(localURL, hash));//False
WWW www = WWW.LoadFromCacheOrDownload(localURL, hash);
yield return www;
Debug.Log(www.error);//Null
Debug.Log(Caching.IsVersionCached(localURL, hash));//True

has strange behaviour. As you can see I wrote wrong Hash128 for the existing bundle. Before downloading this bundle the method Caching.IsVersionCached(localURL, hash) returns False (that is OK). But after downloading (right bundle with wrong hash) this method returns True and no errors in www.error.

Could you help me please?

Well, it’s normal behaviour:)
Caching.IsVersionCached and WWW.LoadFromCacheOrDownload works with version parameter, so in your case:

  1. You calculate some hash value (f. e. it’s 123) and use it as version parameter
  2. You check IsVersionCached for localURL and version 123, but there’s no cached localURL with version 123 → you get False
  3. You LoadFromCacheOrDownload localURL with version 123, but there’s no cached localURL with version 123 → it downloads localURL and caches with version 123
  4. Finally you check IsVersionCached for localURL and version 123 again and that’s it → no www.error and True result, cause localURL with version 123 already exists in the cache

Ty for your reply!