AI-optimized code

This commit is contained in:
2dust 2025-03-06 11:10:55 +08:00
parent d4a8787356
commit c3439c5abe
2 changed files with 7 additions and 3 deletions

View file

@ -15,7 +15,7 @@ namespace ServiceLib.Handler
public static async Task Start(string configPath, int httpPort, int pacPort)
{
_needRestart = (configPath != _configPath || httpPort != _httpPort || pacPort != _pacPort || !_isRunning);
_needRestart = configPath != _configPath || httpPort != _httpPort || pacPort != _pacPort || !_isRunning;
_configPath = configPath;
_httpPort = httpPort;
@ -70,7 +70,7 @@ namespace ServiceLib.Handler
}
var client = await _tcpListener.AcceptTcpClientAsync();
await Task.Run(() => { WriteContent(client); });
await Task.Run(() => WriteContent(client));
}
catch
{
@ -90,7 +90,9 @@ namespace ServiceLib.Handler
public static void Stop()
{
if (_tcpListener == null)
{
return;
}
try
{
_isRunning = false;

View file

@ -8,7 +8,7 @@ namespace ServiceLib.Handler
private static readonly Lazy<WebDavHandler> _instance = new(() => new());
public static WebDavHandler Instance => _instance.Value;
private Config? _config;
private readonly Config? _config;
private WebDavClient? _client;
private string? _lastDescription;
private string _webDir = Global.AppName + "_backup";
@ -62,7 +62,9 @@ namespace ServiceLib.Handler
private async Task<bool> TryCreateDir()
{
if (_client is null)
{
return false;
}
try
{
var result2 = await _client.Mkcol(_webDir);