Skip to content

Commit 23cb395

Browse files
committed
remap binaries correctly
1 parent 6685d60 commit 23cb395

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Intersect.Server/Web/Controllers/AssetManagement/AssetsController.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,28 @@ public IActionResult AssetGet([FromRoute] string? path = default)
100100
var assetFileSystemInfo = AssetFileSystemInfo.From(assetRootPath, pathToInspect);
101101
if (assetFileSystemInfo == default)
102102
{
103+
// ReSharper disable once InvertIf
103104
if (RuntimeIdentifier is { } runtimeIdentifier && !string.IsNullOrWhiteSpace(runtimeIdentifier))
104105
{
105-
var pathToBinary = Path.Combine(assetRootPath, "binaries", RuntimeIdentifier, partialPath);
106-
FileInfo binaryFileInfo = new(pathToBinary);
107-
if (binaryFileInfo.Exists)
106+
var segments = partialPath.Split('/', 2, StringSplitOptions.RemoveEmptyEntries);
107+
var initialSegment = segments.FirstOrDefault();
108+
// ReSharper disable once InvertIf
109+
if (!string.IsNullOrWhiteSpace(initialSegment))
108110
{
109-
return new PhysicalFileResult(binaryFileInfo.FullName, ContentTypes.OctetStream);
111+
var remainingSegments = segments.Skip(1).ToArray();
112+
var combinedRemainingSegments = Path.Combine(remainingSegments);
113+
var pathToBinary = Path.Combine(
114+
assetRootPath,
115+
initialSegment,
116+
"binaries",
117+
RuntimeIdentifier,
118+
combinedRemainingSegments
119+
);
120+
FileInfo binaryFileInfo = new(pathToBinary);
121+
if (binaryFileInfo.Exists)
122+
{
123+
return new PhysicalFileResult(binaryFileInfo.FullName, ContentTypes.OctetStream);
124+
}
110125
}
111126
}
112127

0 commit comments

Comments
 (0)