mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 23:19:53 +08:00
fix file error
This commit is contained in:
@@ -62,7 +62,7 @@ namespace System.Application.Serialization
|
||||
|
||||
lock (_sync)
|
||||
{
|
||||
using var stream = new FileStream(_path, FileMode.Create, FileAccess.ReadWrite);
|
||||
using var stream = new FileStream(_path, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete);
|
||||
if (stream.Position > 0)
|
||||
{
|
||||
stream.Position = 0;
|
||||
@@ -77,7 +77,7 @@ namespace System.Application.Serialization
|
||||
{
|
||||
if (File.Exists(_path))
|
||||
{
|
||||
using var stream = new FileStream(_path, FileMode.Open, FileAccess.Read);
|
||||
using var stream = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
lock (_sync)
|
||||
{
|
||||
if (stream.Position > 0)
|
||||
|
||||
@@ -84,42 +84,52 @@ namespace System.Application.Services.Implementation
|
||||
bool checkReadOnly = false,
|
||||
bool checkMaxLength = true)
|
||||
{
|
||||
message = null;
|
||||
removeReadOnly = false;
|
||||
fileInfo = new FileInfo(s.HostsFilePath);
|
||||
if (!fileInfo.Exists)
|
||||
try
|
||||
{
|
||||
//message = "hosts file was not found";
|
||||
//return false;
|
||||
try
|
||||
message = null;
|
||||
removeReadOnly = false;
|
||||
fileInfo = new FileInfo(s.HostsFilePath);
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
fileInfo.Create().Dispose();
|
||||
return true;
|
||||
//message = "hosts file was not found";
|
||||
//return false;
|
||||
try
|
||||
{
|
||||
fileInfo.Create().Dispose();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.GetAllMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
if (checkMaxLength)
|
||||
{
|
||||
message = ex.GetAllMessage();
|
||||
return false;
|
||||
if (fileInfo.Length > MaxFileLength)
|
||||
{
|
||||
message = "hosts file is too large";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (checkReadOnly)
|
||||
{
|
||||
var attr = fileInfo.Attributes;
|
||||
if (attr.HasFlag(FileAttributes.ReadOnly))
|
||||
{
|
||||
fileInfo.Attributes = attr & ~FileAttributes.ReadOnly;
|
||||
removeReadOnly = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (checkMaxLength)
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (fileInfo.Length > MaxFileLength)
|
||||
{
|
||||
message = "hosts file is too large";
|
||||
return false;
|
||||
}
|
||||
removeReadOnly = false;
|
||||
fileInfo = new FileInfo(s.HostsFilePath);
|
||||
message = ex.Message;
|
||||
return false;
|
||||
}
|
||||
if (checkReadOnly)
|
||||
{
|
||||
var attr = fileInfo.Attributes;
|
||||
if (attr.HasFlag(FileAttributes.ReadOnly))
|
||||
{
|
||||
fileInfo.Attributes = attr & ~FileAttributes.ReadOnly;
|
||||
removeReadOnly = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace System.Application.Services.Implementation
|
||||
{
|
||||
get
|
||||
{
|
||||
return Process.GetProcesses().Any(p => steamProcess.Contains(p.ProcessName, StringComparer.OrdinalIgnoreCase));
|
||||
return Process.GetProcessesByName(steamProcess[0])?.Length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +74,11 @@ namespace System.Application.Services.Implementation
|
||||
{
|
||||
if (steamProcess.Contains(p.ProcessName, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
p.Kill();
|
||||
p.WaitForExit();
|
||||
if (p.HasExited == false)
|
||||
{
|
||||
p.Kill();
|
||||
p.WaitForExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using DynamicData;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ReactiveUI;
|
||||
@@ -487,14 +487,10 @@ namespace System.Application.Services
|
||||
|
||||
public void SaveEditNameAuthenticators()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
var auths = Authenticators.Items.Where(x => x.Name != x.OriginName);
|
||||
|
||||
foreach (var auth in auths)
|
||||
AddOrUpdateSaveAuthenticators(auth);
|
||||
});
|
||||
var auths = Authenticators.Items.Where(x => x.Name != x.OriginName);
|
||||
|
||||
foreach (var auth in auths)
|
||||
AddOrUpdateSaveAuthenticators(auth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ namespace System.Application.Services.Implementation
|
||||
{
|
||||
e.HttpClient.UpStreamEndPoint = new IPEndPoint(ip, item.PortId);
|
||||
}
|
||||
//e.HttpClient.Request.Host = item.ForwardDomainName ?? e.HttpClient.Request.Host;
|
||||
if (e.HttpClient.ConnectRequest?.ClientHelloInfo?.Extensions != null)
|
||||
{
|
||||
//Logger.Info("ClientHelloInfo Info: " + e.HttpClient.ConnectRequest.ClientHelloInfo);
|
||||
|
||||
Reference in New Issue
Block a user