MCPcopy Create free account
hub / github.com/defold/defold / Flush

Function Flush

engine/dlib/src/dlib/http_cache.cpp:365–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363 }
364
365 Result Flush(HCache cache)
366 {
367 dmMutex::ScopedLock lock(cache->m_Mutex);
368 if (!cache->m_Dirty) {
369 return RESULT_OK;
370 }
371
372 cache->m_Dirty = false;
373 dmLogInfo("Flushing http cache to disk");
374
375 char cache_file[DMPATH_MAX_PATH];
376 dmSnPrintf(cache_file, sizeof(cache_file), "%s/%s", cache->m_Path, "index");
377 FILE* f = fopen(cache_file, "wb");
378 if (f) {
379 Result r = WriteIndex(cache, f);
380 fclose(f);
381 if (r != RESULT_OK) {
382 dmLogError("Error writing to index file '%s'", cache_file);
383 dmSys::Unlink(cache_file);
384 return RESULT_IO_ERROR;
385 }
386 } else {
387 dmLogError("Unable to open index file '%s'", cache_file);
388 return RESULT_IO_ERROR;
389 }
390
391 return RESULT_OK;
392 }
393
394 Result Close(HCache cache)
395 {

Callers 2

CloseFunction · 0.70
LoopFunction · 0.50

Calls 3

dmSnPrintfFunction · 0.85
WriteIndexFunction · 0.85
UnlinkFunction · 0.70

Tested by

no test coverage detected