Skip to content

Commit

Permalink
Merge branch 'develop2'
Browse files Browse the repository at this point in the history
  • Loading branch information
yar229 committed Oct 21, 2019
2 parents 7e56f13 + 87e0910 commit da2d9fc
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion MailRuCloud/MailRuCloudApi/Base/Repos/WebM1RequestRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ CustomDisposable<HttpWebResponse> ResponseGenerator(long instart, long inend, Fi
downServer = pendingServers.Next(downServer);
string url =(isLinked
? $"{downServer.Value.Url}{file.PublicLink}"
? $"{downServer.Value.Url}{WebDavPath.EscapeDataString(file.PublicLink)}"
: $"{downServer.Value.Url}{Uri.EscapeDataString(file.FullPath.TrimStart('/'))}") +
$"?client_id={HttpSettings.ClientId}&token={Authent.AccessToken}";
var uri = new Uri(url);
Expand Down
7 changes: 7 additions & 0 deletions MailRuCloud/MailRuCloudApi/Base/WebDavPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ public static bool PathEquals(string path1, string path2)
{
return String.Compare(Clean(path1), Clean(path2), StringComparison.InvariantCultureIgnoreCase) == 0;
}

public static string EscapeDataString(string path)
{
return Uri
.EscapeDataString(path)
.Replace("#", "%23");
}
}

public struct WebDavPathParts
Expand Down
4 changes: 2 additions & 2 deletions MailRuCloud/MailRuCloudApi/MailRuCloudApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks>
<RootNamespace>YaR.MailRuCloud.Api</RootNamespace>
<AssemblyName>MailRuCloud.Api</AssemblyName>
<AssemblyVersion>1.10.7.13</AssemblyVersion>
<FileVersion>1.10.7.13</FileVersion>
<AssemblyVersion>1.10.8.1</AssemblyVersion>
<FileVersion>1.10.8.1</FileVersion>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions WDMRC.Console/WDMRC.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<Copyright>[email protected]</Copyright>
<Description>WebDAV emulator for Cloud.mail.ru</Description>
<PackageId>WebDAVCloudMailRu</PackageId>
<AssemblyVersion>1.10.7.13</AssemblyVersion>
<FileVersion>1.10.7.13</FileVersion>
<AssemblyVersion>1.10.8.1</AssemblyVersion>
<FileVersion>1.10.8.1</FileVersion>
<AssemblyName>wdmrc</AssemblyName>
<RootNamespace>YaR.CloudMailRu.Console</RootNamespace>
<StartupObject></StartupObject>
Expand Down
19 changes: 19 additions & 0 deletions WebDavMailRuCloudStore/Mailru/MkcolHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NWebDav.Server.Helpers;
using NWebDav.Server.Http;
using NWebDav.Server.Stores;
using YaR.MailRuCloud.Api.SpecialCommands;

namespace YaR.WebDavMailRu.CloudStore.Mailru
{
Expand All @@ -27,6 +28,24 @@ public async Task<bool> HandleRequestAsync(IHttpContext httpContext, IStore stor
var request = httpContext.Request;
var response = httpContext.Response;




var destinationPath = request.Url.LocalPath;

var cmdFabric = new SpecialCommandFabric();
var cmd = cmdFabric.Build(CloudManager.Instance(httpContext.Session.Principal.Identity), destinationPath);
if (cmd != null)
{
var res = cmd.Execute().Result;
//if (!res.IsSuccess)
// Logger.Log(LogLevel.Error, res.Message);

response.SetStatus(res.IsSuccess ? DavStatusCode.Created : DavStatusCode.PreconditionFailed);
return true;
}


// The collection must always be created inside another collection
var splitUri = request.Url.Parent;

Expand Down
19 changes: 9 additions & 10 deletions WebDavMailRuCloudStore/Mailru/StoreBase/MailruStoreCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using NWebDav.Server.Props;
using NWebDav.Server.Stores;
using YaR.MailRuCloud.Api.Base;
using YaR.MailRuCloud.Api.SpecialCommands;
using YaR.WebDavMailRu.CloudStore.DavCustomProperty;
using File = YaR.MailRuCloud.Api.Base.File;

Expand Down Expand Up @@ -335,16 +334,16 @@ public Task<StoreCollectionResult> CreateCollectionAsync(string name, bool overw

var destinationPath = WebDavPath.Combine(FullPath, name);

var cmdFabric = new SpecialCommandFabric();
var cmd = cmdFabric.Build(CloudManager.Instance(httpContext.Session.Principal.Identity), destinationPath);
if (cmd != null)
{
var res = cmd.Execute().Result;
if (!res.IsSuccess)
Logger.Log(LogLevel.Error, res.Message);
//var cmdFabric = new SpecialCommandFabric();
//var cmd = cmdFabric.Build(CloudManager.Instance(httpContext.Session.Principal.Identity), destinationPath);
//if (cmd != null)
//{
// var res = cmd.Execute().Result;
// if (!res.IsSuccess)
// Logger.Log(LogLevel.Error, res.Message);

return Task.FromResult(new StoreCollectionResult(res.IsSuccess ? DavStatusCode.Created : DavStatusCode.PreconditionFailed));
}
// return Task.FromResult(new StoreCollectionResult(res.IsSuccess ? DavStatusCode.Created : DavStatusCode.PreconditionFailed));
//}

DavStatusCode result;

Expand Down

0 comments on commit da2d9fc

Please sign in to comment.