mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-03 05:22:10 +00:00
Automatically backup configuration files at startup
This commit is contained in:
parent
eac7361a0b
commit
058e1aafd1
3 changed files with 34 additions and 20 deletions
|
@ -43,6 +43,7 @@ namespace v2rayN.Forms
|
||||||
{
|
{
|
||||||
ConfigHandler.LoadConfig(ref config);
|
ConfigHandler.LoadConfig(ref config);
|
||||||
ConfigHandler.InitBuiltinRouting(ref config);
|
ConfigHandler.InitBuiltinRouting(ref config);
|
||||||
|
MainFormHandler.Instance.BackupGuiNConfig(config, true);
|
||||||
v2rayHandler = new V2rayHandler();
|
v2rayHandler = new V2rayHandler();
|
||||||
v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;
|
v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,14 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BackupGuiNConfig(Config config)
|
public void BackupGuiNConfig(Config config, bool auto = false)
|
||||||
|
{
|
||||||
|
string fileName = string.Empty;
|
||||||
|
if (auto)
|
||||||
|
{
|
||||||
|
fileName = Utils.GetTempPath($"guiNConfig{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.json");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
SaveFileDialog fileDialog = new SaveFileDialog
|
SaveFileDialog fileDialog = new SaveFileDialog
|
||||||
{
|
{
|
||||||
|
@ -249,13 +256,18 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string fileName = fileDialog.FileName;
|
fileName = fileDialog.FileName;
|
||||||
|
}
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (Utils.IsNullOrEmpty(fileName))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Utils.ToJsonFile(config, fileName) == 0)
|
var ret = Utils.ToJsonFile(config, fileName);
|
||||||
|
if (!auto)
|
||||||
{
|
{
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
|
|
||||||
UI.Show(UIRes.I18N("OperationSuccess"));
|
UI.Show(UIRes.I18N("OperationSuccess"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -263,6 +275,7 @@ namespace v2rayN.Handler
|
||||||
UI.ShowWarning(UIRes.I18N("OperationFailed"));
|
UI.ShowWarning(UIRes.I18N("OperationFailed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace v2rayN
|
||||||
if (!IsDuplicateInstance())
|
if (!IsDuplicateInstance())
|
||||||
{
|
{
|
||||||
|
|
||||||
Utils.SaveLog("v2rayN start up " + Utils.GetVersion());
|
Utils.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
|
||||||
|
|
||||||
//设置语言环境
|
//设置语言环境
|
||||||
string lang = Utils.RegReadValue(Global.MyRegPath, Global.MyRegKeyLanguage, "zh-Hans");
|
string lang = Utils.RegReadValue(Global.MyRegPath, Global.MyRegKeyLanguage, "zh-Hans");
|
||||||
|
|
Loading…
Reference in a new issue