Skip to content

Commit

Permalink
Some refactor with "ValidateCopiedFoldersIntegrity"
Browse files Browse the repository at this point in the history
  • Loading branch information
314pies committed Jul 3, 2021
1 parent 44b8322 commit c8834ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion ParrelSync/Editor/ClonesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ public static void OpenProject(string projectPath)
return;
}

ParrelSync.NonCore.ValidateCopiedFoldersIntegrity.ValidateFolder(projectPath, ClonesManager.GetOriginalProjectPath(), "Packages");
//Validate (and update if needed) the "Packages" folder before opening clone project to ensure the clone project will have the
//same "compiling environment" as the original project
ValidateCopiedFoldersIntegrity.ValidateFolder(projectPath, GetOriginalProjectPath(), "Packages");

string fileName = GetApplicationPath();
string args = "-projectPath \"" + projectPath + "\"";
Expand Down
18 changes: 9 additions & 9 deletions ParrelSync/Editor/ValidateCopiedFoldersIntegrity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ParrelSync.NonCore
namespace ParrelSync
{
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -27,18 +27,18 @@ static ValidateCopiedFoldersIntegrity()
}
}

public static void ValidateFolder(string current, string original, string folderName)
public static void ValidateFolder(string targetRoot, string originalRoot, string folderName)
{
var currentProjectPath = Path.Combine(current, folderName);
var currentFolderHash = CreateMd5ForFolder(currentProjectPath);
var targetFolderPath = Path.Combine(targetRoot, folderName);
var targetFolderHash = CreateMd5ForFolder(targetFolderPath);

var originalProjectPath = Path.Combine(original, folderName);
var originalFolderHash = CreateMd5ForFolder(originalProjectPath);
var originalFolderPath = Path.Combine(originalRoot, folderName);
var originalFolderHash = CreateMd5ForFolder(originalFolderPath);

if (currentFolderHash != originalFolderHash)
if (targetFolderHash != originalFolderHash)
{
Debug.Log("ParrelSync: Detected '" + folderName + "' folder changes in the original project. Updating...");
FileUtil.ReplaceDirectory(originalProjectPath, currentProjectPath);
Debug.Log("ParrelSync: Detected changes in '" + folderName + "' directory. Updating cloned project...");
FileUtil.ReplaceDirectory(originalFolderPath, targetFolderPath);
}
}

Expand Down

0 comments on commit c8834ba

Please sign in to comment.