Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Fixed an issue where link validation was failing (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenHodgson authored Apr 29, 2019
1 parent 0483cb4 commit 4bab8f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,16 @@ public static async void RunSync(bool forceUpdate = false)
{
if (string.IsNullOrEmpty(link.SourceRelativePath)) { continue; }

bool isValid = false;
var targetAbsolutePath = $"{ProjectRoot}{link.TargetRelativePath}";
var sourceAbsolutePath = $"{ProjectRoot}{link.SourceRelativePath}";

if (link.IsActive)
{
await VerifySymbolicLink(targetAbsolutePath, sourceAbsolutePath);
isValid = await VerifySymbolicLink(targetAbsolutePath, sourceAbsolutePath);
}

if (Directory.Exists(targetAbsolutePath))
if (isValid)
{
// If we already have the directory in our project, then skip.
if (link.IsActive) { continue; }
Expand Down Expand Up @@ -393,24 +394,28 @@ private static bool DeleteSymbolicLink(string path)
return false;
}

if (new Process().Run($"/C rmdir /q \"{path}\"", out var error))
if (new Process().Run($"/C rmdir /q \"{path}\"", out _))
{
if (File.Exists($"{path}.meta"))
{
File.Delete($"{path}.meta");
}

AssetDatabase.Refresh();
return true;
}

Debug.LogError($"{error}\n{path}");
return false;
return true;
}

private static async Task VerifySymbolicLink(string targetAbsolutePath, string sourceAbsolutePath)
private static async Task<bool> VerifySymbolicLink(string targetAbsolutePath, string sourceAbsolutePath)
{
var pathToVerify = targetAbsolutePath.Substring(0, targetAbsolutePath.LastIndexOf("/", StringComparison.Ordinal));

if (DebugEnabled)
{
Debug.Log($"Attempting to validate {targetAbsolutePath}");
}

var args = $"/C powershell.exe \"& dir '{pathToVerify}' | select Target, LinkType | where {{ $_.LinkType -eq 'SymbolicLink' }} | Format-Table -HideTableHeaders -Wrap\"";

bool success;
Expand All @@ -430,8 +435,8 @@ private static async Task VerifySymbolicLink(string targetAbsolutePath, string s

if (!success)
{
Debug.LogError($"Failed to enumerate symbolic links associated to {pathToVerify}");
return;
Debug.LogError($"Failed to enumerate symbolic links associated to {targetAbsolutePath}");
return false;
}

var isValid = false;
Expand All @@ -452,6 +457,8 @@ private static async Task VerifySymbolicLink(string targetAbsolutePath, string s
{
DeleteSymbolicLink(targetAbsolutePath);
}

return isValid && Directory.Exists(targetAbsolutePath);
}

private static string AddSubfolderPathToTarget(string sourcePath, string targetPath)
Expand Down
2 changes: 1 addition & 1 deletion XRTK-Core/Packages/com.xrtk.core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.xrtk.core",
"displayName": "XRTK.Core",
"description": "The core framework of the Mixed Reality Toolkit",
"version": "0.1.6",
"version": "0.1.7",
"unity": "2019.1",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit 4bab8f3

Please sign in to comment.