From a0bb8efc2b491af3c6a5068addcf6e06284f74f3 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 10 Mar 2026 14:16:08 +0100 Subject: [PATCH] Adjustment for `deleteFileSafety` in #3992 --- Source/Engine/Content/Asset.cpp | 2 +- Source/Engine/Content/Content.cpp | 14 +++++++------- Source/Engine/Content/Content.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Engine/Content/Asset.cpp b/Source/Engine/Content/Asset.cpp index 7a35d3b28..b77f39bb5 100644 --- a/Source/Engine/Content/Asset.cpp +++ b/Source/Engine/Content/Asset.cpp @@ -316,7 +316,7 @@ void Asset::OnDeleteObject() // Delete file if (!IsVirtual()) - Content::deleteFileSafety(path, id); + Content::deleteFileSafety(path, &id); } #endif } diff --git a/Source/Engine/Content/Content.cpp b/Source/Engine/Content/Content.cpp index 4d63368fa..183903c3b 100644 --- a/Source/Engine/Content/Content.cpp +++ b/Source/Engine/Content/Content.cpp @@ -808,7 +808,7 @@ void Content::DeleteScript(const StringView& path) LOG(Info, "Deleting script '{0}'", path); // Delete file - deleteFileSafety(path, Guid::Empty, false); + deleteFileSafety(path); #endif } @@ -840,13 +840,13 @@ void Content::DeleteAsset(const StringView& path) } // Delete file - deleteFileSafety(path, info.ID); + deleteFileSafety(path, &info.ID); #endif } -void Content::deleteFileSafety(const StringView& path, const Guid& id, bool useId) +void Content::deleteFileSafety(const StringView& path, const Guid* id) { - if (!id.IsValid() && useId) + if (id && !id->IsValid()) { LOG(Warning, "Cannot remove file \'{0}\'. Given ID is invalid.", path); return; @@ -855,12 +855,12 @@ void Content::deleteFileSafety(const StringView& path, const Guid& id, bool useI // Ensure that file has the same ID (prevent from deleting different assets) auto storage = ContentStorageManager::TryGetStorage(path); - if (storage && useId) + if (storage && id) { storage->CloseFileHandles(); // Close file handle to allow removing it - if (!storage->HasAsset(id)) + if (!storage->HasAsset(*id)) { - LOG(Warning, "Cannot remove file \'{0}\'. It doesn\'t contain asset {1}.", path, id); + LOG(Warning, "Cannot remove file \'{0}\'. It doesn\'t contain asset {1}.", path, *id); return; } } diff --git a/Source/Engine/Content/Content.h b/Source/Engine/Content/Content.h index 9f0e2eeef..107b51270 100644 --- a/Source/Engine/Content/Content.h +++ b/Source/Engine/Content/Content.h @@ -395,7 +395,7 @@ private: static void onAssetLoaded(Asset* asset); static void onAssetUnload(Asset* asset); static void onAssetChangeId(Asset* asset, const Guid& oldId, const Guid& newId); - static void deleteFileSafety(const StringView& path, const Guid& id, bool useId = true); + static void deleteFileSafety(const StringView& path, const Guid* id = nullptr); // Internal bindings #if !COMPILE_WITHOUT_CSHARP