MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / UpdateCache

Function UpdateCache

src/TexturePack.c:437–454  ·  view source on GitHub ↗

Updates cached data, ETag, and Last-Modified for the given URL */

Source from the content-addressed store, hash-verified

435
436/* Updates cached data, ETag, and Last-Modified for the given URL */
437static void UpdateCache(struct HttpRequest* req) {
438 cc_string url, altPath, value;
439 cc_string path; char pathBuffer[FILENAME_SIZE];
440 cc_result res;
441 url = String_FromRawArray(req->url);
442
443 value = String_FromRawArray(req->etag);
444 SetCachedTag(&url, &etagCache, &value, ETAGS_TXT);
445 value = String_FromRawArray(req->lastModified);
446 SetCachedTag(&url, &lastModCache, &value, LASTMOD_TXT);
447
448 String_InitArray(path, pathBuffer);
449 altPath = String_Empty;
450 MakeCachePath(&path, &altPath, &url);
451
452 res = Stream_WriteAllTo(&path, req->data, req->size);
453 if (res) { Logger_SysWarn2(res, "caching", &url); }
454}
455#else
456static void TextureCache_Init(void) {
457}

Callers 1

ApplyDownloadedFunction · 0.85

Calls 4

SetCachedTagFunction · 0.85
MakeCachePathFunction · 0.85
Stream_WriteAllToFunction · 0.85
Logger_SysWarn2Function · 0.85

Tested by

no test coverage detected