mirror of
https://github.com/2dust/v2rayN.git
synced 2026-10-30 00:55:00 +03:00
Fix
This commit is contained in:
@@ -11,7 +11,7 @@ namespace ServiceLib.Handler
|
|||||||
private Config? _config;
|
private Config? _config;
|
||||||
private WebDavClient? _client;
|
private WebDavClient? _client;
|
||||||
private string? _lastDescription;
|
private string? _lastDescription;
|
||||||
private string _webDir = "mywebdir";
|
private string _webDir = Global.AppName + "_backup";
|
||||||
private string _webFileName = "backup.zip";
|
private string _webFileName = "backup.zip";
|
||||||
private string _logTitle = "WebDav--";
|
private string _logTitle = "WebDav--";
|
||||||
|
|
||||||
@@ -51,17 +51,12 @@ namespace ServiceLib.Handler
|
|||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> CheckProp()
|
private async Task<bool> TryCreateDir()
|
||||||
{
|
{
|
||||||
if (_client is null) return false;
|
if (_client is null) return false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await _client.Propfind(_webDir);
|
var result2 = await _client.Mkcol(_webDir);
|
||||||
if (result.IsSuccessful)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
var result2 = await _client.Mkcol(_webDir); // create a directory
|
|
||||||
if (result2.IsSuccessful)
|
if (result2.IsSuccessful)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -93,12 +88,20 @@ namespace ServiceLib.Handler
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (await CheckProp() == false)
|
await TryCreateDir();
|
||||||
|
|
||||||
|
var testName = "readme_test";
|
||||||
|
var myContent = new StringContent(testName);
|
||||||
|
var result = await _client.PutFile($"{_webDir}/{testName}", myContent);
|
||||||
|
if (result.IsSuccessful)
|
||||||
|
{
|
||||||
|
await _client.Delete($"{_webDir}/{testName}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> PutFile(string fileName)
|
public async Task<bool> PutFile(string fileName)
|
||||||
@@ -107,10 +110,7 @@ namespace ServiceLib.Handler
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (await CheckProp() == false)
|
await TryCreateDir();
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -136,10 +136,8 @@ namespace ServiceLib.Handler
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (await CheckProp() == false)
|
await TryCreateDir();
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var response = await _client.GetRawFile($"{_webDir}/{_webFileName}");
|
var response = await _client.GetRawFile($"{_webDir}/{_webFileName}");
|
||||||
|
|||||||
Reference in New Issue
Block a user