[CHANGE] ApplicationContext removed and related classes. Added Drive info to library info page.
This commit is contained in:
@@ -223,6 +223,7 @@ public class LibraryService : ILibraryService
|
||||
try
|
||||
{
|
||||
await using var context = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
var libraryDriveInfo = GetLibraryDriveInfo(_libraryDirectory);
|
||||
var libInfo = new LibraryInformation
|
||||
{
|
||||
LibraryPath = _libraryDirectory.FullName,
|
||||
@@ -230,7 +231,10 @@ public class LibraryService : ILibraryService
|
||||
LastModifiedUtc = _libraryDirectory.LastWriteTimeUtc,
|
||||
TotalChannels = await context.Channels.CountAsync(cancellationToken: cancellationToken),
|
||||
TotalMedia = await context.Media.CountAsync(cancellationToken: cancellationToken),
|
||||
TotalSizeBytes = GetDirectorySize(_libraryDirectory)
|
||||
TotalSizeBytes = GetDirectorySize(_libraryDirectory),
|
||||
DriveTotalSpaceBytes = libraryDriveInfo.totalSpace,
|
||||
DriveFreeSpaceBytes = libraryDriveInfo.freeSpace,
|
||||
DriveUsedSpaceBytes = libraryDriveInfo.usedSpace
|
||||
};
|
||||
return libInfo;
|
||||
}
|
||||
@@ -352,6 +356,20 @@ public class LibraryService : ILibraryService
|
||||
}
|
||||
}
|
||||
|
||||
private (long totalSpace, long freeSpace, long usedSpace) GetLibraryDriveInfo(DirectoryInfo dir)
|
||||
{
|
||||
try
|
||||
{
|
||||
var drive = new DriveInfo(dir.FullName);
|
||||
return (drive.TotalSize, drive.AvailableFreeSpace, drive.TotalSize - drive.AvailableFreeSpace);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Error while getting directory free space.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ResultError HandleException(Exception exception)
|
||||
{
|
||||
if (exception is OperationCanceledException)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace Manager.App.Services.System;
|
||||
|
||||
public class SettingsService(ILogger<SettingsService> logger) : ExtendedBackgroundService(nameof(SettingsService), "Service for handling application settings.", logger, TimeSpan.FromMinutes(10))
|
||||
{
|
||||
protected override async Task InitializeAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
AddActions([
|
||||
new ServiceAction("Save settings", "Save the application settings to the database", () => { }, () => true)
|
||||
]);
|
||||
}
|
||||
|
||||
protected override async Task ExecuteServiceAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user