Fix file lock when loading asset fails

#1103
This commit is contained in:
Wojtek Figat
2023-05-16 11:52:49 +02:00
parent 1dd8aa3db8
commit a3ab7cd14e
2 changed files with 12 additions and 1 deletions

View File

@@ -760,9 +760,14 @@ bool Content::CloneAssetFile(const StringView& dstPath, const StringView& srcPat
// Change asset ID
{
auto storage = ContentStorageManager::GetStorage(tmpPath);
if (!storage)
{
LOG(Warning, "Cannot change asset ID.");
return true;
}
FlaxStorage::Entry e;
storage->GetEntry(0, e);
if (!storage || storage->ChangeAssetID(e, dstId))
if (storage->ChangeAssetID(e, dstId))
{
LOG(Warning, "Cannot change asset ID.");
return true;

View File

@@ -211,6 +211,12 @@ FlaxStorage::~FlaxStorage()
CHECK(_chunksLock == 0);
CHECK(_refCount == 0);
ASSERT(_chunks.IsEmpty());
#if USE_EDITOR
// Ensure to close any outstanding file handles to prevent file locking in case it failed to load
_file.DeleteAll();
#endif
}
FlaxStorage::LockData FlaxStorage::LockSafe()