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

Commit

Permalink
Fixed symbolic link validation (#687)
Browse files Browse the repository at this point in the history
Made SymbolicLinker public to make it easier to Sync symbolic links in projects using the utility
Made SymbolicLinks.IsActive set public to make it easier to toggle symbolic links on and off
  • Loading branch information
StephenHodgson authored Nov 23, 2020
1 parent 72cc312 commit 9a85eb4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static string SymbolicLinkSettingsPath
string.IsNullOrEmpty(symbolicLinkSettingsPath))
{
symbolicLinkSettingsPath = AssetDatabase
.FindAssets($"t:{typeof(SymbolicLinkSettings).Name}")
.FindAssets($"t:{nameof(SymbolicLinkSettings)}")
.Select(AssetDatabase.GUIDToAssetPath)
.OrderBy(x => x)
.FirstOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ public string TargetRelativePath
public bool IsActive
{
get => isActive;
internal set => isActive = value;
set
{
if (isActive != value)
{
isActive = value;
SymbolicLinker.RunSync(true);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace XRTK.Editor.Utilities.SymbolicLinks
{
[InitializeOnLoad]
internal static class SymbolicLinker
public static class SymbolicLinker
{
/// <summary>
/// Constructor.
Expand Down Expand Up @@ -48,7 +48,7 @@ static SymbolicLinker()
/// <summary>
/// Debug the symbolic linker utility.
/// </summary>
public static bool DebugEnabled
private static bool DebugEnabled
{
get => MixedRealityPreferences.DebugSymbolicInfo;
set => MixedRealityPreferences.DebugSymbolicInfo = value;
Expand Down Expand Up @@ -128,16 +128,10 @@ public static 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)
{
isValid = VerifySymbolicLink(targetAbsolutePath);
}

if (isValid)
if (VerifySymbolicLink(targetAbsolutePath))
{
// If we already have the directory in our project, then skip.
if (link.IsActive) { continue; }
Expand Down Expand Up @@ -202,7 +196,7 @@ public static void RunSync(bool forceUpdate = false)
/// </summary>
/// <param name="sourceAbsolutePath"></param>
/// <param name="targetAbsolutePath"></param>
public static bool AddLink(string sourceAbsolutePath, string targetAbsolutePath)
internal static bool AddLink(string sourceAbsolutePath, string targetAbsolutePath)
{
if (string.IsNullOrEmpty(sourceAbsolutePath) || string.IsNullOrEmpty(targetAbsolutePath))
{
Expand Down Expand Up @@ -256,7 +250,7 @@ public static bool AddLink(string sourceAbsolutePath, string targetAbsolutePath)
/// Disables a symbolic link in the settings.
/// </summary>
/// <param name="targetRelativePath"></param>
public static bool DisableLink(string targetRelativePath)
internal static bool DisableLink(string targetRelativePath)
{
var symbolicLink = Settings.SymbolicLinks.Find(link => link.TargetRelativePath == targetRelativePath);

Expand All @@ -282,7 +276,7 @@ public static bool DisableLink(string targetRelativePath)
/// </summary>
/// <param name="sourceRelativePath"></param>
/// <param name="targetRelativePath"></param>
public static bool RemoveLink(string sourceRelativePath, string targetRelativePath)
internal static bool RemoveLink(string sourceRelativePath, string targetRelativePath)
{
if (!DisableLink(targetRelativePath))
{
Expand Down

0 comments on commit 9a85eb4

Please sign in to comment.