diff --git a/MailRuCloud/MailRuCloudApi/Base/Repos/WebM1RequestRepo.cs b/MailRuCloud/MailRuCloudApi/Base/Repos/WebM1RequestRepo.cs index 08ab1719..cc939a02 100644 --- a/MailRuCloud/MailRuCloudApi/Base/Repos/WebM1RequestRepo.cs +++ b/MailRuCloud/MailRuCloudApi/Base/Repos/WebM1RequestRepo.cs @@ -92,7 +92,7 @@ CustomDisposable 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); diff --git a/MailRuCloud/MailRuCloudApi/Base/WebDavPath.cs b/MailRuCloud/MailRuCloudApi/Base/WebDavPath.cs index 9c8e2359..8b057917 100644 --- a/MailRuCloud/MailRuCloudApi/Base/WebDavPath.cs +++ b/MailRuCloud/MailRuCloudApi/Base/WebDavPath.cs @@ -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 diff --git a/MailRuCloud/MailRuCloudApi/MailRuCloudApi.csproj b/MailRuCloud/MailRuCloudApi/MailRuCloudApi.csproj index 461056ff..f21f80c6 100644 --- a/MailRuCloud/MailRuCloudApi/MailRuCloudApi.csproj +++ b/MailRuCloud/MailRuCloudApi/MailRuCloudApi.csproj @@ -5,8 +5,8 @@ netcoreapp3.0;net461 YaR.MailRuCloud.Api MailRuCloud.Api - 1.10.7.13 - 1.10.7.13 + 1.10.8.1 + 1.10.8.1 7.3 diff --git a/WDMRC.Console/WDMRC.Console.csproj b/WDMRC.Console/WDMRC.Console.csproj index 493ad00d..8c010ab2 100644 --- a/WDMRC.Console/WDMRC.Console.csproj +++ b/WDMRC.Console/WDMRC.Console.csproj @@ -11,8 +11,8 @@ yar229@yandex.ru WebDAV emulator for Cloud.mail.ru WebDAVCloudMailRu - 1.10.7.13 - 1.10.7.13 + 1.10.8.1 + 1.10.8.1 wdmrc YaR.CloudMailRu.Console diff --git a/WebDavMailRuCloudStore/Mailru/MkcolHandler.cs b/WebDavMailRuCloudStore/Mailru/MkcolHandler.cs index 0b8d5727..cb4cb1df 100644 --- a/WebDavMailRuCloudStore/Mailru/MkcolHandler.cs +++ b/WebDavMailRuCloudStore/Mailru/MkcolHandler.cs @@ -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 { @@ -27,6 +28,24 @@ public async Task 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; diff --git a/WebDavMailRuCloudStore/Mailru/StoreBase/MailruStoreCollection.cs b/WebDavMailRuCloudStore/Mailru/StoreBase/MailruStoreCollection.cs index bbd4f3c6..4ba67d37 100644 --- a/WebDavMailRuCloudStore/Mailru/StoreBase/MailruStoreCollection.cs +++ b/WebDavMailRuCloudStore/Mailru/StoreBase/MailruStoreCollection.cs @@ -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; @@ -335,16 +334,16 @@ public Task 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;