mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Prevents the theme detection job from crashing the host on file system errors
This commit is contained in:
1 parent
a7e722321c
commit
a09876525b
1 file changed
+14
@@ -72,6 +72,11 @@ internal sealed class ThemeDetectionSyncJob : BackgroundService
|
|||||||
if (knownThemeIds.Contains(manifestResult.Value.Id))
|
if (knownThemeIds.Contains(manifestResult.Value.Id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// installing a bundled theme at startup is best effort: a file system failure here must never crash the host,
|
||||||
|
// because the default BackgroundServiceExceptionBehavior (StopHost) shuts down the whole application and
|
||||||
|
// disposes its service provider, making every later request fail
|
||||||
|
try
|
||||||
|
{
|
||||||
await using FileStream archive = File.OpenRead(archivePath);
|
await using FileStream archive = File.OpenRead(archivePath);
|
||||||
Result<ThemeManifestDto> installResult = await _themeService.InstallAsync(archive, stoppingToken);
|
Result<ThemeManifestDto> installResult = await _themeService.InstallAsync(archive, stoppingToken);
|
||||||
if (installResult.IsFailure)
|
if (installResult.IsFailure)
|
||||||
@@ -102,6 +107,15 @@ internal sealed class ThemeDetectionSyncJob : BackgroundService
|
|||||||
else
|
else
|
||||||
themes.Add(themeEntity);
|
themes.Add(themeEntity);
|
||||||
}
|
}
|
||||||
|
catch (IOException exception)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(exception, "Failed to install bundled theme '{ThemeId}': the theme files could not be written.", manifestResult.Value.Id);
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException exception)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(exception, "Failed to install bundled theme '{ThemeId}': access to the theme files was denied.", manifestResult.Value.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await CleanUpMissingThemePacksAsync(unitOfWork, themes, stoppingToken);
|
await CleanUpMissingThemePacksAsync(unitOfWork, themes, stoppingToken);
|
||||||
await EnsureCurrentThemeExistsAsync(unitOfWork, themes, stoppingToken);
|
await EnsureCurrentThemeExistsAsync(unitOfWork, themes, stoppingToken);
|
||||||
|
|||||||
Reference in new issue
Block a user