summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCallum Prentice <callum@lindenlab.com>2021-03-09 18:33:35 -0800
committerCallum Prentice <callum@lindenlab.com>2021-03-09 18:33:35 -0800
commitd7518c7b4f5eca731d0ea143bab34b279bd4ee13 (patch)
tree2c8955444b44bb88ae89e451fe17c0144984b929
parent168d177197bd7558bbe0ca13d01c984ad8638da7 (diff)
Ansariel kindly offered their patch to help mitigate this round of file system issues - taken from https://vcs.firestormviewer.org/phoenix-firestorm/changeset/104a8600946be01e2de44d10ad069ba854272d1f
-rw-r--r--indra/llfilesystem/lldiskcache.cpp4
-rw-r--r--indra/llfilesystem/llfilesystem.cpp27
-rw-r--r--indra/newview/llmeshrepository.cpp34
3 files changed, 58 insertions, 7 deletions
diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp
index c9f7684b5a..61eb654693 100644
--- a/indra/llfilesystem/lldiskcache.cpp
+++ b/indra/llfilesystem/lldiskcache.cpp
@@ -192,8 +192,8 @@ const std::string LLDiskCache::metaDataToFilepath(const std::string id,
file_path << id;
file_path << "_";
file_path << (extra_info.empty() ? "0" : extra_info);
- //file_path << "_";
- //file_path << assetTypeToString(at); // see SL-14210 Prune descriptive tag from new cache filenames
+ file_path << "_";
+ file_path << assetTypeToString(at); // see SL-14210 Prune descriptive tag from new cache filenames
// for details of why it was removed. Note that if you put it
// back or change the format of the filename, the cache files
// files will be invalidated (and perhaps, more importantly,
diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp
index 053b52014e..da44e8d98c 100644
--- a/indra/llfilesystem/llfilesystem.cpp
+++ b/indra/llfilesystem/llfilesystem.cpp
@@ -200,9 +200,36 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes)
{
ofs.write((const char*)buffer, bytes);
+ mPosition = ofs.tellp(); // <FS:Ansariel> Fix asset caching
+
+ success = TRUE;
+ }
+ }
+ // <FS:Ansariel> Fix asset caching
+ else if (mMode == READ_WRITE)
+ {
+ // Don't truncate if file already exists
+ llofstream ofs(filename, std::ios::in | std::ios::binary);
+ if (ofs)
+ {
+ ofs.seekp(mPosition, std::ios::beg);
+ ofs.write((const char*)buffer, bytes);
+ mPosition += bytes;
success = TRUE;
}
+ else
+ {
+ // File doesn't exist - open in write mode
+ ofs.open(filename, std::ios::binary);
+ if (ofs.is_open())
+ {
+ ofs.write((const char*)buffer, bytes);
+ mPosition += bytes;
+ success = TRUE;
+ }
+ }
}
+ // </FS:Ansariel>
else
{
llofstream ofs(filename, std::ios::binary);
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 8e5bdc0225..c2404a7e67 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -3248,13 +3248,29 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b
// only allocate as much space in the cache as is needed for the local cache
data_size = llmin(data_size, bytes);
- LLFileSystem file(mesh_id, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ // <FS:Ansariel> Fix asset caching
+ //LLFileSystem file(mesh_id, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE);
if (file.getMaxSize() >= bytes)
{
LLMeshRepository::sCacheBytesWritten += data_size;
++LLMeshRepository::sCacheWrites;
file.write(data, data_size);
+
+ // <FS:Ansariel> Fix asset caching
+ S32 remaining = bytes - file.tell();
+ if (remaining > 0)
+ {
+ U8* block = new(std::nothrow) U8[remaining];
+ if (block)
+ {
+ memset(block, 0, remaining);
+ file.write(block, remaining);
+ delete[] block;
+ }
+ }
+ // </FS:Ansariel>
}
}
else
@@ -3307,7 +3323,9 @@ void LLMeshLODHandler::processData(LLCore::BufferArray * /* body */, S32 /* body
if (result == MESH_OK)
{
// good fetch from sim, write to cache
- LLFileSystem file(mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ // <FS:Ansariel> Fix asset caching
+ //LLFileSystem file(mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ LLFileSystem file(mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLFileSystem::READ_WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;
@@ -3371,7 +3389,9 @@ void LLMeshSkinInfoHandler::processData(LLCore::BufferArray * /* body */, S32 /*
&& gMeshRepo.mThread->skinInfoReceived(mMeshID, data, data_size))
{
// good fetch from sim, write to cache
- LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ // <FS:Ansariel> Fix asset caching
+ //LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;
@@ -3419,7 +3439,9 @@ void LLMeshDecompositionHandler::processData(LLCore::BufferArray * /* body */, S
&& gMeshRepo.mThread->decompositionReceived(mMeshID, data, data_size))
{
// good fetch from sim, write to cache
- LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ // <FS:Ansariel> Fix asset caching
+ //LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;
@@ -3466,7 +3488,9 @@ void LLMeshPhysicsShapeHandler::processData(LLCore::BufferArray * /* body */, S3
&& gMeshRepo.mThread->physicsShapeReceived(mMeshID, data, data_size) == MESH_OK)
{
// good fetch from sim, write to cache for caching
- LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ // <FS:Ansariel> Fix asset caching
+ //LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;