From fc5862c91d7c579cbc3e381191f3283b4c6dca66 Mon Sep 17 00:00:00 2001 From: guoyongchang Date: Sat, 5 Sep 2020 21:38:06 +0800 Subject: [PATCH] Allow upload empty vmesses to github. --- v2rayN/v2rayN/Forms/MainForm.cs | 3 ++- v2rayN/v2rayN/Resx/ResUI.Designer.cs | 9 +++++++++ v2rayN/v2rayN/Resx/ResUI.resx | 3 +++ v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx | 3 +++ v2rayN/v2rayN/Tool/GithubRemoteStorageHelper.cs | 6 +++++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index a4265831..3f88e67e 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -1687,8 +1687,9 @@ namespace v2rayN.Forms } try { await GithubRemoteStorageHelper.Fetch(config.vmess, githubRemoteStorageConfig); - RefreshServers(); UI.Show(UIRes.I18N("GithubRemoteStoreFetchSucceed")); + RefreshServers(); + ConfigHandler.SaveConfig(ref config); } catch (Octokit.AuthorizationException githubAuthException) { AppendText(githubAuthException.Message); diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs index 348b51dc..7925874d 100644 --- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs +++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs @@ -258,6 +258,15 @@ namespace v2rayN.Resx { } } + /// + /// 查找类似 There is no data in the local Vmess list. After uploading, the remote configuration file (if have) will be cleared. Are you sure you want to do this? 的本地化字符串。 + /// + internal static string GithubRemoteStorageLocalVmessIsEmpty { + get { + return ResourceManager.GetString("GithubRemoteStorageLocalVmessIsEmpty", resourceCulture); + } + } + /// /// 查找类似 Github authentication failed, please check the settings 的本地化字符串。 /// diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index 4be46377..2da1ad4e 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -183,6 +183,9 @@ Failed to download the configuration file from Github, the configuration file was not found on Github, please check the settings.If it is the first time, you can upload to Github first. + + There is no data in the local Vmess list. After uploading, the remote configuration file (if have) will be cleared. Are you sure you want to do this? + Github authentication failed, please check the settings diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx index fa91a941..6721cdcf 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -183,6 +183,9 @@ 从Github下载配置文件失败,没有在Github找到配置文件,请检查设置。如果是第一次可以先上传到Github + + 本地Vmess列表没有数据,上传后会清空远端配置文件(如有),确定要这么做吗 + Github认证失败,请检查设置 diff --git a/v2rayN/v2rayN/Tool/GithubRemoteStorageHelper.cs b/v2rayN/v2rayN/Tool/GithubRemoteStorageHelper.cs index cc1aa1d8..7e470d42 100644 --- a/v2rayN/v2rayN/Tool/GithubRemoteStorageHelper.cs +++ b/v2rayN/v2rayN/Tool/GithubRemoteStorageHelper.cs @@ -2,11 +2,13 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Drawing.Text; using System.Linq; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; using v2rayN.Mode; using v2rayN.Protos.Statistics; @@ -46,7 +48,9 @@ namespace v2rayN.Tool { /// public static async Task Upload(IList localVmessItems, GithubRemoteStorageConfig config) { if (localVmessItems?.Any() != true) { - return; + if (DialogResult.No == UI.ShowYesNo(UIRes.I18N("GithubRemoteStorageLocalVmessIsEmpty"))) { + return; + } } var vmessesJson = Newtonsoft.Json.JsonConvert.SerializeObject(localVmessItems); var client = GetClient(config);