Skip to content

Commit 7211da4

Browse files
author
Stewart Miles
committed
Fixed asset rename to disable when a disabled file exists.
Bug: 131100117 Change-Id: I4a9c57a1094f1c76c23dbb8ee96c36a7300ea1bd
1 parent 6359efa commit 7211da4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

source/VersionHandlerImpl/src/VersionHandlerImpl.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,16 @@ private static void SetFileEnabledByRename(FileMetadata metadata, bool enabled)
19191919
}
19201920

19211921
Log("Renaming file " + filename + " to " + newFilename, verbose: true);
1922-
AssetDatabase.MoveAsset(filename, newFilename);
1922+
bool movedAsset = true;
1923+
if (File.Exists(newFilename)) {
1924+
movedAsset = AssetDatabase.MoveAssetToTrash(newFilename);
1925+
}
1926+
string moveError = AssetDatabase.MoveAsset(filename, newFilename);
1927+
movedAsset &= String.IsNullOrEmpty(moveError);
1928+
if (!movedAsset) {
1929+
Log(String.Format("Unable to disable {0} ({1})", filename, moveError),
1930+
level: LogLevel.Error);
1931+
}
19231932
}
19241933

19251934
// Returns the major/minor version of the unity environment we are running in

0 commit comments

Comments
 (0)