diff --git a/Source/Editor/Modules/ContentDatabaseModule.cs b/Source/Editor/Modules/ContentDatabaseModule.cs
index 01f8bf8d0..f270f119f 100644
--- a/Source/Editor/Modules/ContentDatabaseModule.cs
+++ b/Source/Editor/Modules/ContentDatabaseModule.cs
@@ -344,7 +344,13 @@ namespace FlaxEditor.Modules
return null;
}
- private static void RenameAsset(ContentItem el, ref string newPath)
+ ///
+ /// Renames a content item
+ ///
+ /// Content item
+ /// New path
+ /// True if failed, otherwise false
+ private static bool RenameAsset(ContentItem el, ref string newPath)
{
string oldPath = el.Path;
@@ -357,7 +363,7 @@ namespace FlaxEditor.Modules
{
// Error
Editor.LogError(string.Format("Cannot rename asset \'{0}\' to \'{1}\'", oldPath, newPath));
- return;
+ return true;
}
}
else
@@ -372,12 +378,13 @@ namespace FlaxEditor.Modules
// Error
Editor.LogWarning(ex);
Editor.LogError(string.Format("Cannot rename asset \'{0}\' to \'{1}\'", oldPath, newPath));
- return;
+ return true;
}
}
// Change path
el.UpdatePath(newPath);
+ return false;
}
private static void UpdateAssetNewNameTree(ContentItem el)
@@ -464,12 +471,6 @@ namespace FlaxEditor.Modules
MessageBox.Show("Cannot move folder. Target location already exists.");
return;
}
- if (!item.IsFolder && File.Exists(newPath))
- {
- // Error
- MessageBox.Show("Cannot move file. Target location already exists.");
- return;
- }
// Find target parent
var newDirPath = Path.GetDirectoryName(newPath);
@@ -526,7 +527,11 @@ namespace FlaxEditor.Modules
}
else
{
- RenameAsset(item, ref newPath);
+ if (RenameAsset(item, ref newPath))
+ {
+ MessageBox.Show("Cannot rename item.");
+ return;
+ }
}
if (item.ParentFolder != null)
diff --git a/Source/Engine/Content/Content.cpp b/Source/Engine/Content/Content.cpp
index 78d0ff1d6..ed2fba1dc 100644
--- a/Source/Engine/Content/Content.cpp
+++ b/Source/Engine/Content/Content.cpp
@@ -574,7 +574,7 @@ bool Content::RenameAsset(const StringView& oldPath, const StringView& newPath)
Asset* newAsset = GetAsset(newPath);
// Validate name
- if (newAsset != nullptr || FileSystem::FileExists(newPath))
+ if (newAsset != nullptr && newAsset != oldAsset)
{
LOG(Error, "Invalid name '{0}' when trying to rename '{1}'.", newPath, oldPath);
return true;