diff --git a/src/dotnet/APIView/APIViewWeb/LeanControllers/ReviewsController.cs b/src/dotnet/APIView/APIViewWeb/LeanControllers/ReviewsController.cs index bda76aa782c..990bde0a407 100644 --- a/src/dotnet/APIView/APIViewWeb/LeanControllers/ReviewsController.cs +++ b/src/dotnet/APIView/APIViewWeb/LeanControllers/ReviewsController.cs @@ -137,8 +137,7 @@ public async Task> GetReviewContentAsync(string revi if (activeAPIRevision.Files[0].ParserStyle == ParserStyle.Tree) { var comments = await _commentsManager.GetCommentsAsync(reviewId); - var cachedCodeFile = await _codeFileRepository.GetCodeFileAsync(revisionId: activeAPIRevision.Id, codeFileId: activeAPIRevision.Files[0].FileId); - var activeRevisionReviewCodeFile = cachedCodeFile.CodeFile; + var activeRevisionReviewCodeFile = await _codeFileRepository.GetCodeFileFromStorageAsync(revisionId: activeAPIRevision.Id, codeFileId: activeAPIRevision.Files[0].FileId); var codePanelRawData = new CodePanelRawData() { @@ -149,8 +148,7 @@ public async Task> GetReviewContentAsync(string revi if (!string.IsNullOrEmpty(diffApiRevisionId)) { var diffAPIRevision = await _apiRevisionsManager.GetAPIRevisionAsync(User, diffApiRevisionId); - var diffCodeFile = await _codeFileRepository.GetCodeFileAsync(revisionId: diffAPIRevision.Id, codeFileId: diffAPIRevision.Files[0].FileId); - codePanelRawData.diffRevisionCodeFile = diffCodeFile.CodeFile; + codePanelRawData.diffRevisionCodeFile = await _codeFileRepository.GetCodeFileFromStorageAsync(revisionId: diffAPIRevision.Id, codeFileId: diffAPIRevision.Files[0].FileId); } // Render the code files to generate UI token tree diff --git a/src/dotnet/APIView/APIViewWeb/Repositories/BlobCodeFileRepository.cs b/src/dotnet/APIView/APIViewWeb/Repositories/BlobCodeFileRepository.cs index a1846cef758..549d42870ea 100644 --- a/src/dotnet/APIView/APIViewWeb/Repositories/BlobCodeFileRepository.cs +++ b/src/dotnet/APIView/APIViewWeb/Repositories/BlobCodeFileRepository.cs @@ -36,12 +36,7 @@ public Task GetCodeFileAsync(APIRevisionListItemModel revision public async Task GetCodeFileAsync(string revisionId, APICodeFileModel apiCodeFile, string language, bool updateCache = true) { - return await GetCodeFileAsync(revisionId, apiCodeFile.FileId, updateCache, apiCodeFile.ParserStyle == ParserStyle.Tree); - } - - public async Task GetCodeFileAsync(string revisionId, string codeFileId, bool updateCache = true, bool doTreeStyleParserDeserialization = true) - { - var client = GetBlobClient(revisionId, codeFileId, out var key); + var client = GetBlobClient(revisionId, apiCodeFile.FileId, out var key); if (_cache.TryGetValue(key, out var codeFile)) { return codeFile; @@ -49,7 +44,7 @@ public async Task GetCodeFileAsync(string revisionId, string c var info = await client.DownloadAsync(); - codeFile = new RenderedCodeFile(await CodeFile.DeserializeAsync(info.Value.Content, doTreeStyleParserDeserialization)); + codeFile = new RenderedCodeFile(await CodeFile.DeserializeAsync(info.Value.Content, false)); if (updateCache) { @@ -58,6 +53,14 @@ public async Task GetCodeFileAsync(string revisionId, string c .SetValue(codeFile); } return codeFile; + } + + public async Task GetCodeFileFromStorageAsync(string revisionId, string codeFileId, bool doTreeStyleParserDeserialization = true) + { + var client = GetBlobClient(revisionId, codeFileId, out var key); + var info = await client.DownloadAsync(); + var codeFile = await CodeFile.DeserializeAsync(info.Value.Content, doTreeStyleParserDeserialization); + return codeFile; } public async Task UpsertCodeFileAsync(string revisionId, string codeFileId, CodeFile codeFile) diff --git a/src/dotnet/APIView/APIViewWeb/Repositories/Interfaces/IBlobCodeFileRepository.cs b/src/dotnet/APIView/APIViewWeb/Repositories/Interfaces/IBlobCodeFileRepository.cs index 20995751fb2..ab0c39b13c5 100644 --- a/src/dotnet/APIView/APIViewWeb/Repositories/Interfaces/IBlobCodeFileRepository.cs +++ b/src/dotnet/APIView/APIViewWeb/Repositories/Interfaces/IBlobCodeFileRepository.cs @@ -9,8 +9,8 @@ public interface IBlobCodeFileRepository { public Task GetCodeFileAsync(APIRevisionListItemModel revision, bool updateCache = true); public Task GetCodeFileAsync(string revisionId, APICodeFileModel apiCodeFile, string language, bool updateCache = true); - public Task GetCodeFileAsync(string revisionId, string codeFileId, bool updateCache = true, bool doTreeStyleParserDeserialization = true); public Task UpsertCodeFileAsync(string revisionId, string codeFileId, CodeFile codeFile); public Task DeleteCodeFileAsync(string revisionId, string codeFileId); + public Task GetCodeFileFromStorageAsync(string revisionId, string codeFileId, bool doTreeStyleParserDeserialization = true); } }