fix: Fix type mismatch errors and nullable warnings
- Updated type conversions for MinimumSeedRatio from float to int - Fixed UserPreferencesConfig references to use UserPreferences class - Added null checks for Path operations in PostProcessor - Changed arrays to Lists for MediaExtensions and NotificationEvents - Added null checks in MetricsService for DriveInfo paths - Added default values for nullable string properties - Fixed missing using statements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f21639455d
commit
2e2e38d979
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -7,6 +8,7 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using TransmissionRssManager.Core;
|
using TransmissionRssManager.Core;
|
||||||
|
using TransmissionRssManager.Services;
|
||||||
|
|
||||||
namespace TransmissionRssManager.Api.Controllers
|
namespace TransmissionRssManager.Api.Controllers
|
||||||
{
|
{
|
||||||
@ -178,20 +180,20 @@ namespace TransmissionRssManager.Api.Controllers
|
|||||||
Enabled = false,
|
Enabled = false,
|
||||||
ExtractArchives = true,
|
ExtractArchives = true,
|
||||||
OrganizeMedia = true,
|
OrganizeMedia = true,
|
||||||
MinimumSeedRatio = 1.0f,
|
MinimumSeedRatio = 1,
|
||||||
MediaExtensions = new[] { ".mp4", ".mkv", ".avi", ".mov", ".wmv", ".m4v", ".mpg", ".mpeg", ".flv", ".webm" },
|
MediaExtensions = new List<string> { ".mp4", ".mkv", ".avi", ".mov", ".wmv", ".m4v", ".mpg", ".mpeg", ".flv", ".webm" },
|
||||||
AutoOrganizeByMediaType = true,
|
AutoOrganizeByMediaType = true,
|
||||||
RenameFiles = false,
|
RenameFiles = false,
|
||||||
CompressCompletedFiles = false,
|
CompressCompletedFiles = false,
|
||||||
DeleteCompletedAfterDays = 0
|
DeleteCompletedAfterDays = 0
|
||||||
},
|
},
|
||||||
UserPreferences = new UserPreferencesConfig
|
UserPreferences = new UserPreferences
|
||||||
{
|
{
|
||||||
EnableDarkMode = true,
|
EnableDarkMode = true,
|
||||||
AutoRefreshUIEnabled = true,
|
AutoRefreshUIEnabled = true,
|
||||||
AutoRefreshIntervalSeconds = 30,
|
AutoRefreshIntervalSeconds = 30,
|
||||||
NotificationsEnabled = true,
|
NotificationsEnabled = true,
|
||||||
NotificationEvents = new[] { "torrent-added", "torrent-completed", "torrent-error" },
|
NotificationEvents = new List<string> { "torrent-added", "torrent-completed", "torrent-error" },
|
||||||
DefaultView = "dashboard",
|
DefaultView = "dashboard",
|
||||||
ConfirmBeforeDelete = true,
|
ConfirmBeforeDelete = true,
|
||||||
MaxItemsPerPage = 25,
|
MaxItemsPerPage = 25,
|
||||||
|
@ -83,7 +83,7 @@ namespace TransmissionRssManager.Api.Controllers
|
|||||||
|
|
||||||
public class AddTorrentRequest
|
public class AddTorrentRequest
|
||||||
{
|
{
|
||||||
public string Url { get; set; }
|
public string Url { get; set; } = string.Empty;
|
||||||
public string DownloadDir { get; set; }
|
public string DownloadDir { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ namespace TransmissionRssManager.Services
|
|||||||
{
|
{
|
||||||
private readonly ILogger<ConfigService> _logger;
|
private readonly ILogger<ConfigService> _logger;
|
||||||
private readonly string _configFilePath;
|
private readonly string _configFilePath;
|
||||||
private AppConfig _cachedConfig;
|
private AppConfig? _cachedConfig;
|
||||||
private readonly object _lockObject = new object();
|
private readonly object _lockObject = new object();
|
||||||
|
|
||||||
public ConfigService(ILogger<ConfigService> logger)
|
public ConfigService(ILogger<ConfigService> logger)
|
||||||
@ -407,9 +407,9 @@ namespace TransmissionRssManager.Services
|
|||||||
Enabled = false,
|
Enabled = false,
|
||||||
ExtractArchives = true,
|
ExtractArchives = true,
|
||||||
OrganizeMedia = true,
|
OrganizeMedia = true,
|
||||||
MinimumSeedRatio = 1.0f
|
MinimumSeedRatio = 1
|
||||||
},
|
},
|
||||||
UserPreferences = new UserPreferencesConfig
|
UserPreferences = new UserPreferences
|
||||||
{
|
{
|
||||||
EnableDarkMode = true,
|
EnableDarkMode = true,
|
||||||
AutoRefreshUIEnabled = true,
|
AutoRefreshUIEnabled = true,
|
||||||
@ -436,10 +436,10 @@ namespace TransmissionRssManager.Services
|
|||||||
Enabled = false,
|
Enabled = false,
|
||||||
ExtractArchives = true,
|
ExtractArchives = true,
|
||||||
OrganizeMedia = true,
|
OrganizeMedia = true,
|
||||||
MinimumSeedRatio = 1.0f
|
MinimumSeedRatio = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
config.UserPreferences ??= new UserPreferencesConfig
|
config.UserPreferences ??= new UserPreferences
|
||||||
{
|
{
|
||||||
EnableDarkMode = true,
|
EnableDarkMode = true,
|
||||||
AutoRefreshUIEnabled = true,
|
AutoRefreshUIEnabled = true,
|
||||||
|
@ -95,9 +95,13 @@ namespace TransmissionRssManager.Services
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var driveInfo = new System.IO.DriveInfo(System.IO.Path.GetPathRoot(downloadDir));
|
var root = System.IO.Path.GetPathRoot(downloadDir);
|
||||||
|
if (!string.IsNullOrEmpty(root))
|
||||||
|
{
|
||||||
|
var driveInfo = new System.IO.DriveInfo(root);
|
||||||
availableSpace = driveInfo.AvailableFreeSpace;
|
availableSpace = driveInfo.AvailableFreeSpace;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, $"Error getting available disk space for {downloadDir}");
|
_logger.LogWarning(ex, $"Error getting available disk space for {downloadDir}");
|
||||||
|
@ -119,9 +119,16 @@ namespace TransmissionRssManager.Services
|
|||||||
{
|
{
|
||||||
_logger.LogInformation($"Extracting archive: {archiveFile}");
|
_logger.LogInformation($"Extracting archive: {archiveFile}");
|
||||||
|
|
||||||
var extractDir = Path.Combine(
|
var dirName = Path.GetDirectoryName(archiveFile);
|
||||||
Path.GetDirectoryName(archiveFile),
|
var fileName = Path.GetFileNameWithoutExtension(archiveFile);
|
||||||
Path.GetFileNameWithoutExtension(archiveFile));
|
|
||||||
|
if (dirName == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning($"Could not get directory name for archive: {archiveFile}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var extractDir = Path.Combine(dirName, fileName);
|
||||||
|
|
||||||
if (!Directory.Exists(extractDir))
|
if (!Directory.Exists(extractDir))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user