Skip to content
Snippets Groups Projects
Commit 0c3b7810 authored by Callum Prentice's avatar Callum Prentice
Browse files

Another tweak for 'SL-15547: Viewer hung while looking for a file in cache' -...

Another tweak for 'SL-15547: Viewer hung while looking for a file in cache' - this time based on Henri's suggestion in this discussion: https://bitbucket.org/lindenlab/viewer/commits/e28c1b46e9944f0215a13cab8ee7dded88d7fc90#comment-10537114
parent 484aa963
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,28 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_ ...@@ -48,6 +48,28 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_
mPosition = 0; mPosition = 0;
mBytesRead = 0; mBytesRead = 0;
mMode = mode; mMode = mode;
// This block of code was originally called in the read() method but after comments here:
// https://bitbucket.org/lindenlab/viewer/commits/e28c1b46e9944f0215a13cab8ee7dded88d7fc90#comment-10537114
// we decided to follow Henri's suggestion and move the code to update the last access time here.
if (mode == LLFileSystem::READ)
{
// build the filename (TODO: we do this in a few places - perhaps we should factor into a single function)
std::string id;
mFileID.toString(id);
const std::string extra_info = "";
const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id, mFileType, extra_info);
// update the last access time for the file if it exists - this is required
// even though we are reading and not writing because this is the
// way the cache works - it relies on a valid "last accessed time" for
// each file so it knows how to remove the oldest, unused files
bool exists = gDirUtilp->fileExists(filename);
if (exists)
{
LLDiskCache::getInstance()->updateFileAccessTime(filename);
}
}
} }
LLFileSystem::~LLFileSystem() LLFileSystem::~LLFileSystem()
...@@ -133,7 +155,7 @@ S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType fi ...@@ -133,7 +155,7 @@ S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType fi
BOOL LLFileSystem::read(U8* buffer, S32 bytes) BOOL LLFileSystem::read(U8* buffer, S32 bytes)
{ {
BOOL success = TRUE; BOOL success = FALSE;
std::string id; std::string id;
mFileID.toString(id); mFileID.toString(id);
...@@ -159,24 +181,11 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes) ...@@ -159,24 +181,11 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes)
file.close(); file.close();
mPosition += mBytesRead; mPosition += mBytesRead;
if (!mBytesRead) if (mBytesRead)
{ {
success = FALSE; success = TRUE;
} }
} }
else
{
success = FALSE;
}
if (success == TRUE)
{
// update the last access time for the file - this is required
// even though we are reading and not writing because this is the
// way the cache works - it relies on a valid "last accessed time" for
// each file so it knows how to remove the oldest, unused files
LLDiskCache::getInstance()->updateFileAccessTime(filename);
}
return success; return success;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment