Merge pull request #508 from emohandesi/fix/public-data-import-httpclient
Fix public data import failing with ObjectDisposedException
This commit is contained in:
commit
de82d2cca6
@ -8,6 +8,7 @@ using RSecurityBackend.Services.Implementation;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -55,6 +56,9 @@ namespace RMuseum.Services.Implementation
|
|||||||
(
|
(
|
||||||
async token =>
|
async token =>
|
||||||
{
|
{
|
||||||
|
// the injected _httpClient is request-scoped and already disposed by the
|
||||||
|
// time this queued work item runs, so the job owns its own client
|
||||||
|
using HttpClient importHttpClient = new HttpClient() { Timeout = TimeSpan.FromMinutes(5) };
|
||||||
using (RMuseumDbContext context = new RMuseumDbContext(new DbContextOptions<RMuseumDbContext>()))
|
using (RMuseumDbContext context = new RMuseumDbContext(new DbContextOptions<RMuseumDbContext>()))
|
||||||
{
|
{
|
||||||
LongRunningJobProgressServiceEF jobProgressServiceEF = new LongRunningJobProgressServiceEF(context);
|
LongRunningJobProgressServiceEF jobProgressServiceEF = new LongRunningJobProgressServiceEF(context);
|
||||||
@ -63,7 +67,7 @@ namespace RMuseum.Services.Implementation
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IPublicDataSource source = useHttp
|
IPublicDataSource source = useHttp
|
||||||
? new HttpPublicDataSource(_httpClient, location)
|
? new HttpPublicDataSource(importHttpClient, location)
|
||||||
: new LocalFileSystemPublicDataSource(location);
|
: new LocalFileSystemPublicDataSource(location);
|
||||||
|
|
||||||
string manifestJson = await source.ReadTextAsync("manifest.json");
|
string manifestJson = await source.ReadTextAsync("manifest.json");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user