From e634e6dae3b9d20c64fa6aea6ea16436e7da56f0 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Thu, 13 Nov 2025 20:31:02 +0800 Subject: [PATCH] Code clean --- v2rayN/ServiceLib/Manager/CertPemManager.cs | 4 +++ v2rayN/ServiceLib/Services/UpdateService.cs | 28 ++++++++++----------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/v2rayN/ServiceLib/Manager/CertPemManager.cs b/v2rayN/ServiceLib/Manager/CertPemManager.cs index 9421aabf..247b5842 100644 --- a/v2rayN/ServiceLib/Manager/CertPemManager.cs +++ b/v2rayN/ServiceLib/Manager/CertPemManager.cs @@ -374,11 +374,15 @@ public class CertPemManager { var beginIndex = pemChain.IndexOf(beginMarker, index, StringComparison.Ordinal); if (beginIndex == -1) + { break; + } var endIndex = pemChain.IndexOf(endMarker, beginIndex, StringComparison.Ordinal); if (endIndex == -1) + { break; + } // Extract certificate content var base64Start = beginIndex + beginMarker.Length; diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index d71719a0..a1d72655 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -17,17 +17,17 @@ public class UpdateService(Config config, Func updateFunc) { if (args.Success) { - UpdateFunc(false, ResUI.MsgDownloadV2rayCoreSuccessfully); - UpdateFunc(true, Utils.UrlEncode(fileName)); + _ = UpdateFunc(false, ResUI.MsgDownloadV2rayCoreSuccessfully); + _ = UpdateFunc(true, Utils.UrlEncode(fileName)); } else { - UpdateFunc(false, args.Msg); + _ = UpdateFunc(false, args.Msg); } }; downloadHandle.Error += (sender2, args) => { - UpdateFunc(false, args.GetException().Message); + _ = UpdateFunc(false, args.GetException().Message); }; await UpdateFunc(false, string.Format(ResUI.MsgStartUpdating, ECoreType.v2rayN)); @@ -57,26 +57,26 @@ public class UpdateService(Config config, Func updateFunc) { if (args.Success) { - UpdateFunc(false, ResUI.MsgDownloadV2rayCoreSuccessfully); - UpdateFunc(false, ResUI.MsgUnpacking); + _ = UpdateFunc(false, ResUI.MsgDownloadV2rayCoreSuccessfully); + _ = UpdateFunc(false, ResUI.MsgUnpacking); try { - UpdateFunc(true, fileName); + _ = UpdateFunc(true, fileName); } catch (Exception ex) { - UpdateFunc(false, ex.Message); + _ = UpdateFunc(false, ex.Message); } } else { - UpdateFunc(false, args.Msg); + _ = UpdateFunc(false, args.Msg); } }; downloadHandle.Error += (sender2, args) => { - UpdateFunc(false, args.GetException().Message); + _ = UpdateFunc(false, args.GetException().Message); }; await UpdateFunc(false, string.Format(ResUI.MsgStartUpdating, type)); @@ -439,7 +439,7 @@ public class UpdateService(Config config, Func updateFunc) { if (args.Success) { - UpdateFunc(false, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, fileName)); + _ = UpdateFunc(false, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, fileName)); try { @@ -453,17 +453,17 @@ public class UpdateService(Config config, Func updateFunc) } catch (Exception ex) { - UpdateFunc(false, ex.Message); + _ = UpdateFunc(false, ex.Message); } } else { - UpdateFunc(false, args.Msg); + _ = UpdateFunc(false, args.Msg); } }; downloadHandle.Error += (sender2, args) => { - UpdateFunc(false, args.GetException().Message); + _ = UpdateFunc(false, args.GetException().Message); }; await downloadHandle.DownloadFileAsync(url, tmpFileName, true, _timeout);