diff --git a/v2rayN/ServiceLib/Handler/WebDavHandler.cs b/v2rayN/ServiceLib/Handler/WebDavHandler.cs index fd1d5e55c4..652c43f284 100644 --- a/v2rayN/ServiceLib/Handler/WebDavHandler.cs +++ b/v2rayN/ServiceLib/Handler/WebDavHandler.cs @@ -35,6 +35,14 @@ private async Task GetClient() _client?.Dispose(); _client = null; } + if (_config.webDavItem.dirName.IsNullOrEmpty()) + { + _webDir = Global.AppName + "_backup"; + } + else + { + _webDir = _config.webDavItem.dirName.TrimEx(); + } var clientParams = new WebDavClientParams { @@ -145,6 +153,7 @@ public async Task GetRawFile(string fileName) if (!response.IsSuccessful) { SaveLog(response.Description); + return false; } using var outputFileStream = new FileStream(fileName, FileMode.Create); response.Stream.CopyTo(outputFileStream); diff --git a/v2rayN/ServiceLib/Models/ConfigItems.cs b/v2rayN/ServiceLib/Models/ConfigItems.cs index ec09ab6f93..d29d6c35a5 100644 --- a/v2rayN/ServiceLib/Models/ConfigItems.cs +++ b/v2rayN/ServiceLib/Models/ConfigItems.cs @@ -255,5 +255,6 @@ public class WebDavItem public string? url { get; set; } public string? userName { get; set; } public string? password { get; set; } + public string? dirName { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index dadb11ed6e..a7e2a98bdc 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -591,6 +591,15 @@ public static string LvWebDavCheck { } } + /// + /// 查找类似 Remote folder name (optional) 的本地化字符串。 + /// + public static string LvWebDavDirName { + get { + return ResourceManager.GetString("LvWebDavDirName", resourceCulture); + } + } + /// /// 查找类似 WebDav Password 的本地化字符串。 /// diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx index 87971fbc9c..615ba3c4e3 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.resx @@ -1312,4 +1312,7 @@ WebDav Check + + Remote folder name (optional) + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx index d6ae1fc2cd..cc652cd3a1 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -1309,4 +1309,7 @@ WebDav 服务器地址 + + 远程文件夹名称(可选) + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx index 571243c911..1da20edc6f 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -1189,4 +1189,7 @@ WebDav 服務器地址 + + 遠端資料夾名稱(可選) + \ No newline at end of file diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs index 1e3d0d0703..9fca6a70b4 100644 --- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs @@ -117,6 +117,11 @@ public async Task LocalRestore(string fileName) { return; } + //exist + if (!File.Exists(fileName)) + { + return; + } //backup first var fileBackup = Utils.GetBackupPath($"backup_{DateTime.Now:yyyyMMddHHmmss}.zip"); diff --git a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml index fc4a0bb622..16b41c4421 100644 --- a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml +++ b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml @@ -130,6 +130,7 @@ + @@ -184,9 +185,25 @@ VerticalAlignment="Center" Style="{StaticResource DefTextBox}" /> + + + +