Skip to content

Commit c0de1fc

Browse files
committed
Check some special cases for URI paths instead of local file paths
1 parent b845a91 commit c0de1fc

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/LibraryManager.Contracts/FileHelpers.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,12 @@ public static string NormalizePath(string path)
387387
return path;
388388
}
389389

390+
// If the path is a URI, we don't want to normalize it
391+
if (IsHttpUri(path))
392+
{
393+
return path;
394+
}
395+
390396
// net451 does not have the OSPlatform apis to determine if the OS is windows or not.
391397
// This also does not handle the fact that MacOS can be configured to be either sensitive or insenstive
392398
// to the casing.
@@ -400,5 +406,14 @@ public static string NormalizePath(string path)
400406

401407
return Path.GetFullPath(path).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
402408
}
409+
410+
/// <summary>
411+
/// Determines if the path is an HTTP or HTTPS Uri
412+
/// </summary>
413+
public static bool IsHttpUri(string path)
414+
{
415+
return Uri.TryCreate(path, UriKind.Absolute, out Uri uri)
416+
&& (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps);
417+
}
403418
}
404419
}

src/LibraryManager.Contracts/LibraryInstallationGoalState.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ public bool IsAchieved()
4141
{
4242
foreach (KeyValuePair<string, string> kvp in InstalledFiles)
4343
{
44+
// If the source file is a remote Uri, we have no way to determine if it matches the installed file.
45+
// So we will always reinstall the library in this case.
46+
if (FileHelpers.IsHttpUri(kvp.Value))
47+
{
48+
return false;
49+
}
50+
4451
var destinationFile = new FileInfo(kvp.Key);
4552
var cacheFile = new FileInfo(kvp.Value);
4653

0 commit comments

Comments
 (0)