Browse Source

Fix index problem

pull/20077/head
Salih 2 years ago
parent
commit
aed8e90447
  1. 16
      modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs
  2. 12
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/GitHub/Documents/GithubDocumentSource.cs

16
modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs

@ -383,12 +383,22 @@ namespace Volo.Docs.Documents
return await GetDocumentAsync(documentName, project, languageCode, version);
}
if (document.LastCachedTime + _cacheTimeout < DateTime.Now)
if (document.LastCachedTime + _cacheTimeout >= DateTime.Now)
{
return await GetDocumentAsync(documentName, project, languageCode, version, document);
return CreateDocumentWithDetailsDto(project, document);
}
return CreateDocumentWithDetailsDto(project, document);
try
{
return await GetDocumentAsync(documentName, project, languageCode, version, document);
}
catch
{
Logger.LogWarning(
"Could not retrieve the document ({documentName}, {languageCode}, {version}) from the source. Using the cached version.",
documentName, languageCode, version);
return CreateDocumentWithDetailsDto(project, document);
}
}
protected virtual DocumentWithDetailsDto CreateDocumentWithDetailsDto(Project project, Document document)

12
modules/docs/src/Volo.Docs.Domain/Volo/Docs/GitHub/Documents/GithubDocumentSource.cs

@ -410,18 +410,6 @@ namespace Volo.Docs.GitHub.Documents
return await _githubRepositoryManager.GetFileRawStringContentAsync(rawDocumentUrl, token, userAgent);
}
catch (HttpRequestException ex)
{
Logger.LogWarning($"Could not retrieve the document ({rawDocumentUrl}) from Github. Trying to get it from database...");
var document = await _documentRepository.FindAsync(project.Id, documentName, languageCode, version);
if (document == null)
{
throw new DocumentNotFoundException(rawDocumentUrl);
}
return document.Content;
}
catch (Exception ex)
{
//TODO: Only handle when document is really not available

Loading…
Cancel
Save