Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Sep 8, 2024
1 parent 8361b4e commit 07156cb
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 1 deletion.
9 changes: 9 additions & 0 deletions v2rayN/ServiceLib/Handler/WebDavHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ private async Task<bool> GetClient()
_client?.Dispose();
_client = null;
}
if (_config.webDavItem.dirName.IsNullOrEmpty())
{
_webDir = Global.AppName + "_backup";
}
else
{
_webDir = _config.webDavItem.dirName.TrimEx();
}

var clientParams = new WebDavClientParams
{
Expand Down Expand Up @@ -145,6 +153,7 @@ public async Task<bool> GetRawFile(string fileName)
if (!response.IsSuccessful)
{
SaveLog(response.Description);
return false;
}
using var outputFileStream = new FileStream(fileName, FileMode.Create);
response.Stream.CopyTo(outputFileStream);
Expand Down
1 change: 1 addition & 0 deletions v2rayN/ServiceLib/Models/ConfigItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
9 changes: 9 additions & 0 deletions v2rayN/ServiceLib/Resx/ResUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions v2rayN/ServiceLib/Resx/ResUI.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1312,4 +1312,7 @@
<data name="LvWebDavCheck" xml:space="preserve">
<value>WebDav Check</value>
</data>
<data name="LvWebDavDirName" xml:space="preserve">
<value>Remote folder name (optional)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1309,4 +1309,7 @@
<data name="LvWebDavUrl" xml:space="preserve">
<value>WebDav 服务器地址</value>
</data>
<data name="LvWebDavDirName" xml:space="preserve">
<value>远程文件夹名称(可选)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1189,4 +1189,7 @@
<data name="LvWebDavUrl" xml:space="preserve">
<value>WebDav 服務器地址</value>
</data>
<data name="LvWebDavDirName" xml:space="preserve">
<value>遠端資料夾名稱(可選)</value>
</data>
</root>
5 changes: 5 additions & 0 deletions v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
19 changes: 18 additions & 1 deletion v2rayN/v2rayN/Views/BackupAndRestoreView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -184,9 +185,25 @@
VerticalAlignment="Center"
Style="{StaticResource DefTextBox}" />

<TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="8"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.LvWebDavDirName}" />

<TextBox
x:Name="txtWebDavDirName"
Grid.Row="3"
Grid.Column="1"
Margin="8"
VerticalAlignment="Center"
Style="{StaticResource DefTextBox}" />

<Button
x:Name="menuWebDavCheck"
Grid.Row="3"
Grid.Row="4"
Grid.Column="1"
Margin="8"
VerticalAlignment="Center"
Expand Down
2 changes: 2 additions & 0 deletions v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public BackupAndRestoreView()
this.Bind(ViewModel, vm => vm.SelectedSource.url, v => v.txtWebDavUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.userName, v => v.txtWebDavUserName.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.password, v => v.txtWebDavPassword.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.dirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.WebDavCheckCmd, v => v.menuWebDavCheck).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RemoteBackupCmd, v => v.menuRemoteBackup).DisposeWith(disposables);
Expand Down

0 comments on commit 07156cb

Please sign in to comment.