mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-25 09:44:42 +00:00
Compare commits
3 commits
5ae58e6a98
...
a6479fe0d0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6479fe0d0 | ||
|
|
4ad4e27dc1 | ||
|
|
7370684985 |
5 changed files with 44 additions and 62 deletions
5
.github/workflows/build-windows.yml
vendored
5
.github/workflows/build-windows.yml
vendored
|
|
@ -29,6 +29,11 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd v2rayN
|
||||
|
|
|
|||
|
|
@ -196,5 +196,26 @@ namespace ServiceLib.Common
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteExpiredFiles(string sourceDir, DateTime dtLine)
|
||||
{
|
||||
try
|
||||
{
|
||||
var files = Directory.GetFiles(sourceDir, "*.*");
|
||||
foreach (var filePath in files)
|
||||
{
|
||||
var file = new FileInfo(filePath);
|
||||
if (file.CreationTime >= dtLine)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
file.Delete();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,36 +25,6 @@ namespace ServiceLib.Common
|
|||
}
|
||||
}
|
||||
|
||||
public static void ClearLogs()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var now = DateTime.Now.AddMonths(-1);
|
||||
var dir = Utils.GetLogPath();
|
||||
var files = Directory.GetFiles(dir, "*.txt");
|
||||
foreach (var filePath in files)
|
||||
{
|
||||
var file = new FileInfo(filePath);
|
||||
if (file.CreationTime >= now) continue;
|
||||
try
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void SaveLog(string strContent)
|
||||
{
|
||||
if (!LogManager.IsLoggingEnabled()) return;
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@
|
|||
{
|
||||
Logging.SaveLog($"v2rayN start up | {Utils.GetRuntimeInfo()}");
|
||||
Logging.LoggingEnabled(_config.GuiItem.EnableLog);
|
||||
Logging.ClearLogs();
|
||||
ClearTemps();
|
||||
|
||||
ClearExpiredFiles();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -92,33 +92,12 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
private void ClearTemps()
|
||||
private void ClearExpiredFiles()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var now = DateTime.Now.AddMonths(-1);
|
||||
var dir = Utils.GetTempPath();
|
||||
var files = Directory.GetFiles(dir, "*.*");
|
||||
foreach (var filePath in files)
|
||||
{
|
||||
var file = new FileInfo(filePath);
|
||||
if (file.CreationTime >= now) continue;
|
||||
try
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
FileManager.DeleteExpiredFiles(Utils.GetLogPath(), DateTime.Now.AddMonths(-1));
|
||||
FileManager.DeleteExpiredFiles(Utils.GetTempPath(), DateTime.Now.AddMonths(-1));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#endregion Menu
|
||||
|
||||
private bool _hasNextReloadJob = false;
|
||||
|
||||
#region Init
|
||||
|
||||
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
|
|
@ -534,14 +536,12 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#region core job
|
||||
|
||||
public async Task Reload(int times = 0)
|
||||
public async Task Reload()
|
||||
{
|
||||
//If there are unfinished reload job, wait a few seconds and exec again.
|
||||
//If there are unfinished reload job, marked with next job.
|
||||
if (!BlReloadEnabled)
|
||||
{
|
||||
await Task.Delay(3000);
|
||||
if (times > 3) return;
|
||||
await Reload(++times);
|
||||
_hasNextReloadJob = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -552,12 +552,19 @@ namespace ServiceLib.ViewModels
|
|||
await SysProxyHandler.UpdateSysProxy(_config, false);
|
||||
|
||||
_updateView?.Invoke(EViewAction.DispatcherReload, null);
|
||||
|
||||
BlReloadEnabled = true;
|
||||
if (_hasNextReloadJob)
|
||||
{
|
||||
_hasNextReloadJob = false;
|
||||
await Reload();
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadResult()
|
||||
{
|
||||
// BlReloadEnabled = true;
|
||||
//Locator.Current.GetService<StatusBarViewModel>()?.ChangeSystemProxyAsync(_config.systemProxyItem.sysProxyType, false);
|
||||
BlReloadEnabled = true;
|
||||
ShowClashUI = _config.IsRunningCore(ECoreType.sing_box);
|
||||
if (ShowClashUI)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue