Skip to content

Commit d5f7101

Browse files
loic-sharmaahehl
andauthored
Accept more symbol download URL patterns (loic-sharma#666)
Support symbol requests with the following URL patterns: 1. {key}ffffffff 2. {key}1 3. {key} Addresses loic-sharma#224 Co-authored-by: ahehl <[email protected]>
1 parent 4379105 commit d5f7101

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/BaGet.Core/Storage/SymbolStorageService.cs

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ private string GetPathForKey(string filename, string key)
6363
throw new ArgumentException(nameof(key));
6464
}
6565

66+
// The key's first 32 characters are the GUID, the remaining characters are the age.
67+
// See: https://github.com/dotnet/symstore/blob/98717c63ec8342acf8a07aa5c909b88bd0c664cc/docs/specs/SSQP_Key_Conventions.md#portable-pdb-signature
68+
// Debuggers should always use the age "ffffffff", however Visual Studio 2019
69+
// users have reported other age values. We will ignore the age.
70+
key = key.Substring(0, 32) + "ffffffff";
71+
6672
return Path.Combine(
6773
SymbolsPathPrefix,
6874
filename.ToLowerInvariant(),

tests/BaGet.Tests/ApiIntegrationTests.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,16 @@ public async Task SymbolDownloadReturnsOk()
374374
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
375375
}
376376

377-
[Fact]
378-
public async Task PrefixedSymbolDownloadReturnsOk()
377+
[Theory]
378+
[InlineData("api/download/symbols/testdata.pdb/16F71ED8DD574AA2AD4A22D29E9C981B1/testdata.pdb")]
379+
[InlineData("api/download/symbols/testdata.pdb/16F71ED8DD574AA2AD4A22D29E9C981B/testdata.pdb")]
380+
[InlineData("api/download/symbols/testprefix/testdata.pdb/16F71ED8DD574AA2AD4A22D29E9C981Bffffffff/testdata.pdb")]
381+
public async Task MalformedSymbolDownloadReturnsOk(string uri)
379382
{
380383
await _factory.AddPackageAsync(_packageStream);
381384
await _factory.AddSymbolPackageAsync(_symbolPackageStream);
382385

383-
using var response = await _client.GetAsync(
384-
"api/download/symbols/testprefix/testdata.pdb/16F71ED8DD574AA2AD4A22D29E9C981Bffffffff/testdata.pdb");
386+
using var response = await _client.GetAsync(uri);
385387

386388
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
387389
}

0 commit comments

Comments
 (0)