Merge pull request #508 from emohandesi/fix/public-data-import-httpclient

Fix public data import failing with ObjectDisposedException
This commit is contained in:
Hamid Reza Mohammadi 2026-09-14 15:43:04 +03:30 committed by GitHub
commit de82d2cca6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,6 +8,7 @@ using RSecurityBackend.Services.Implementation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
@ -55,6 +56,9 @@ namespace RMuseum.Services.Implementation
(
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>()))
{
LongRunningJobProgressServiceEF jobProgressServiceEF = new LongRunningJobProgressServiceEF(context);
@ -63,7 +67,7 @@ namespace RMuseum.Services.Implementation
try
{
IPublicDataSource source = useHttp
? new HttpPublicDataSource(_httpClient, location)
? new HttpPublicDataSource(importHttpClient, location)
: new LocalFileSystemPublicDataSource(location);
string manifestJson = await source.ReadTextAsync("manifest.json");