Fixing cache system for DU files.

This commit is contained in:
Jonathas Costa
2017-10-11 18:20:38 -04:00
parent 7ff8064ef2
commit 75783a5352
2 changed files with 20 additions and 17 deletions

View File

@@ -832,7 +832,7 @@ namespace openspace {
}
LINFO("Saving cache");
success &= saveCachedFile(cachedFile);
//success &= saveCachedFile(cachedFile);
}
}
@@ -1104,10 +1104,12 @@ namespace openspace {
for (int i = 0; i < nItems; ++i) {
int32_t keySize = 0;
fileStream.read(reinterpret_cast<char*>(&keySize), sizeof(int32_t));
char * key = new char[keySize + 1];
key[keySize] = '\0';
std::string key;
for (int c = 0; c < keySize; ++c) {
fileStream.read(reinterpret_cast<char*>(&key[c]), sizeof(int32_t));
char t[2];
t[1] = '\0';
fileStream.read(reinterpret_cast<char*>(&t), sizeof(int32_t));
key.append(t);
}
int32_t value = 0;
fileStream.read(reinterpret_cast<char*>(&value), sizeof(int32_t));

View File

@@ -60,7 +60,7 @@ namespace {
const char* GigaparsecUnit = "Gpc";
const char* GigalightyearUnit = "Gly";
const int8_t CurrentCacheVersion = 1;
const int8_t CurrentCacheVersion = 2;
const float PARSEC = 0.308567756E17f;
enum BlendMode {
@@ -670,7 +670,7 @@ namespace openspace {
}
LINFO("Saving cache");
success &= saveCachedFile(cachedFile);
//success &= saveCachedFile(cachedFile);
}
}
@@ -681,17 +681,18 @@ namespace openspace {
ghoul::filesystem::CacheManager::Persistent::Yes
);
bool hasCachedFile = FileSys.fileExists(cachedFile);
if (hasCachedFile) {
LINFO("Cached file '" << cachedFile << "' used for Label file '" << labelFile << "'");
success &= loadCachedFile(cachedFile);
if (!success) {
FileSys.cacheManager()->removeCacheFile(labelFile);
// Intentional fall-through to the 'else' computation to generate the cache
// file for the next run
}
}
else {
//if (hasCachedFile) {
// LINFO("Cached file '" << cachedFile << "' used for Label file '" << labelFile << "'");
//
// success &= loadCachedFile(cachedFile);
// if (!success) {
// FileSys.cacheManager()->removeCacheFile(labelFile);
// // Intentional fall-through to the 'else' computation to generate the cache
// // file for the next run
// }
//}
//else
{
LINFO("Cache for Label file '" << labelFile << "' not found");
LINFO("Loading Label file '" << labelFile << "'");