Adjustment for deleteFileSafety in #3992
This commit is contained in:
@@ -316,7 +316,7 @@ void Asset::OnDeleteObject()
|
||||
|
||||
// Delete file
|
||||
if (!IsVirtual())
|
||||
Content::deleteFileSafety(path, id);
|
||||
Content::deleteFileSafety(path, &id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user