Allow upload empty vmesses to github.

This commit is contained in:
guoyongchang 2020-09-05 21:38:06 +08:00
parent 0d02b4c345
commit fc5862c91d
5 changed files with 22 additions and 2 deletions

View file

@ -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);

View file

@ -258,6 +258,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 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? 的本地化字符串。
/// </summary>
internal static string GithubRemoteStorageLocalVmessIsEmpty {
get {
return ResourceManager.GetString("GithubRemoteStorageLocalVmessIsEmpty", resourceCulture);
}
}
/// <summary>
/// 查找类似 Github authentication failed, please check the settings 的本地化字符串。
/// </summary>

View file

@ -183,6 +183,9 @@
<data name="GithubRemoteStorageConfigNotFound" xml:space="preserve">
<value>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.</value>
</data>
<data name="GithubRemoteStorageLocalVmessIsEmpty" xml:space="preserve">
<value>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?</value>
</data>
<data name="GithubRemoteStoreAuthorizationFailed" xml:space="preserve">
<value>Github authentication failed, please check the settings</value>
</data>

View file

@ -183,6 +183,9 @@
<data name="GithubRemoteStorageConfigNotFound" xml:space="preserve">
<value>从Github下载配置文件失败没有在Github找到配置文件请检查设置。如果是第一次可以先上传到Github</value>
</data>
<data name="GithubRemoteStorageLocalVmessIsEmpty" xml:space="preserve">
<value>本地Vmess列表没有数据上传后会清空远端配置文件如有确定要这么做吗</value>
</data>
<data name="GithubRemoteStoreAuthorizationFailed" xml:space="preserve">
<value>Github认证失败请检查设置</value>
</data>

View file

@ -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,8 +48,10 @@ namespace v2rayN.Tool {
/// <returns></returns>
public static async Task Upload(IList<VmessItem> localVmessItems, GithubRemoteStorageConfig config) {
if (localVmessItems?.Any() != true) {
if (DialogResult.No == UI.ShowYesNo(UIRes.I18N("GithubRemoteStorageLocalVmessIsEmpty"))) {
return;
}
}
var vmessesJson = Newtonsoft.Json.JsonConvert.SerializeObject(localVmessItems);
var client = GetClient(config);
var repo = await client.Repository.Get(config.userName, config.repoName);