Fix asset storage handling when file is locked

https://github.com/LOOPDISK/FlaxEngine/pull/45
This commit is contained in:
2026-06-02 15:54:36 +02:00
parent 24654e5b02
commit 777602fee6
3 changed files with 7 additions and 6 deletions
+1 -4
View File
@@ -564,10 +564,7 @@ ContentLoadTask* BinaryAsset::createLoadingTask()
loadTask = preLoadChunksTask;
}
// Before asset loading we have to initialize storage
// TODO: maybe in build game we could do it in place?
// This step is only for opening asset files in background and upgrading them
// In build game we have only a few packages which are ready to use
// Before asset loading we have to initialize storage and pull the asset header
auto initTask = New<InitAssetTask>(this);
initTask->ContinueWith(loadTask);
loadTask = initTask;
+2 -2
View File
@@ -378,13 +378,13 @@ void AssetsCache::GetAllByTypeName(const StringView& typeName, Array<Guid>& resu
void AssetsCache::RegisterAssets(FlaxStorage* storage)
{
PROFILE_CPU();
ASSERT(storage);
// Get all entries
Array<FlaxStorage::Entry> entries;
storage->GetEntries(entries);
ASSERT(entries.HasItems());
if (entries.IsEmpty())
return;
ASSETS_CACHE_LOCK();
auto storagePath = storage->GetPath();
@@ -54,6 +54,7 @@ FlaxStorageReference ContentStorageManager::GetStorage(const StringView& path, b
Locker.Lock();
// Try fast lookup
bool wasCached = true;
FlaxStorage* storage;
if (!StorageMap.TryGet(path, storage))
{
@@ -74,6 +75,7 @@ FlaxStorageReference ContentStorageManager::GetStorage(const StringView& path, b
// Register storage container
StorageMap.Add(path, storage);
wasCached = false;
}
// Build reference (before releasing the lock so ContentStorageSystem::Job won't delete it when running from async thread)
@@ -90,6 +92,8 @@ FlaxStorageReference ContentStorageManager::GetStorage(const StringView& path, b
if (loadFailed)
{
LOG(Error, "Failed to load {0}.", path);
if (wasCached)
return result;
Locker.Lock();
StorageMap.Remove(path);
if (storage->IsPackage())