Skip to content

Commit

Permalink
Accept more symbol download URL patterns (#666)
Browse files Browse the repository at this point in the history
Support symbol requests with the following URL patterns:
 
1. {key}ffffffff
2. {key}1
3. {key}

Addresses #224

Co-authored-by: ahehl <78979516+ahehl@users.noreply.github.com>
  • Loading branch information
loic-sharma and ahehl authored Jul 12, 2021
1 parent 4379105 commit d5f7101
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/BaGet.Core/Storage/SymbolStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ private string GetPathForKey(string filename, string key)
throw new ArgumentException(nameof(key));
}

// The key's first 32 characters are the GUID, the remaining characters are the age.
// See: https://github.com/dotnet/symstore/blob/98717c63ec8342acf8a07aa5c909b88bd0c664cc/docs/specs/SSQP_Key_Conventions.md#portable-pdb-signature
// Debuggers should always use the age "ffffffff", however Visual Studio 2019
// users have reported other age values. We will ignore the age.
key = key.Substring(0, 32) + "ffffffff";

return Path.Combine(
SymbolsPathPrefix,
filename.ToLowerInvariant(),
Expand Down
10 changes: 6 additions & 4 deletions tests/BaGet.Tests/ApiIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,16 @@ public async Task SymbolDownloadReturnsOk()
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Fact]
public async Task PrefixedSymbolDownloadReturnsOk()
[Theory]
[InlineData("api/download/symbols/testdata.pdb/16F71ED8DD574AA2AD4A22D29E9C981B1/testdata.pdb")]
[InlineData("api/download/symbols/testdata.pdb/16F71ED8DD574AA2AD4A22D29E9C981B/testdata.pdb")]
[InlineData("api/download/symbols/testprefix/testdata.pdb/16F71ED8DD574AA2AD4A22D29E9C981Bffffffff/testdata.pdb")]
public async Task MalformedSymbolDownloadReturnsOk(string uri)
{
await _factory.AddPackageAsync(_packageStream);
await _factory.AddSymbolPackageAsync(_symbolPackageStream);

using var response = await _client.GetAsync(
"api/download/symbols/testprefix/testdata.pdb/16F71ED8DD574AA2AD4A22D29E9C981Bffffffff/testdata.pdb");
using var response = await _client.GetAsync(uri);

Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
Expand Down

0 comments on commit d5f7101

Please sign in to comment.