Skip to content

Commit 8b402ea

Browse files
fix: Prevent self-copy of analytics_win.dll in Play Mode
This commit refines the logic in `AnalyticsPlayModeSetup.cs` to correctly handle the scenario where `analytics_win.dll` (the source) is already located in the project root (the destination for Play Mode). Previously, if the DLL was in the project root, the `File.Copy` operation would attempt to copy the file onto itself, resulting in an `IOException`. Changes in `editor/app/src/AnalyticsPlayModeSetup.cs`: - Before attempting to copy the DLL for Play Mode: - The full canonical paths of the source and destination are now compared. - If the source and destination paths are identical (i.e., the DLL is already in the project root), the copy operation is skipped, and an informational message is logged. - The file copy (with its try-catch block) only proceeds if the source and destination paths are different. This prevents an unnecessary `IOException` and ensures the setup is cleaner when the DLL is already correctly placed for Play Mode.
1 parent 949ac29 commit 8b402ea

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

editor/app/src/AnalyticsPlayModeSetup.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ private static void OnPlayModeStateChanged(PlayModeStateChange state) {
1919
Type firebaseAnalyticsType = Type.GetType(FirebaseAnalyticsEditorConstants.AnalyticsTypeFullName);
2020
if (firebaseAnalyticsType != null) {
2121
if (File.Exists(FirebaseAnalyticsEditorConstants.DllSourcePath)) {
22+
string fullSourcePath = Path.GetFullPath(FirebaseAnalyticsEditorConstants.DllSourcePath);
23+
// string destinationDirectory = "./"; // This is DestinationDir
24+
string fullDestinationPath = Path.GetFullPath(Path.Combine(DestinationDir, FirebaseAnalyticsEditorConstants.DllName));
25+
26+
if (fullSourcePath.Equals(fullDestinationPath, StringComparison.OrdinalIgnoreCase)) {
27+
Debug.Log("Firebase Analytics: " + FirebaseAnalyticsEditorConstants.DllName + " is already in the project root. No copy needed for Play Mode.");
28+
return;
29+
}
30+
2231
try {
2332
Directory.CreateDirectory(DestinationDir); // Should be benign for "./"
2433
string destinationDllPath = Path.Combine(DestinationDir, FirebaseAnalyticsEditorConstants.DllName);

0 commit comments

Comments
 (0)