diff --git a/MailRuCloud/MailRuCloudApi/Base/Folder.cs b/MailRuCloud/MailRuCloudApi/Base/Folder.cs index a0b87dfe..26d7704b 100644 --- a/MailRuCloud/MailRuCloudApi/Base/Folder.cs +++ b/MailRuCloud/MailRuCloudApi/Base/Folder.cs @@ -115,7 +115,11 @@ public IEnumerable GetPublicLinks(Cloud cloud) public bool IsChildsLoaded { get; internal set; } - public PublishInfo ToPublishInfo() + + public int? ServerFoldersCount { get; set; } + public int? ServerFilesCount { get; set; } + + public PublishInfo ToPublishInfo() { var info = new PublishInfo(); if (PublicLinks.Any()) diff --git a/MailRuCloud/MailRuCloudApi/Base/Repos/MailRuCloud/DtoImport.cs b/MailRuCloud/MailRuCloudApi/Base/Repos/MailRuCloud/DtoImport.cs index f336055d..f06b61f0 100644 --- a/MailRuCloud/MailRuCloudApi/Base/Repos/MailRuCloud/DtoImport.cs +++ b/MailRuCloud/MailRuCloudApi/Base/Repos/MailRuCloud/DtoImport.cs @@ -175,7 +175,11 @@ public static Dictionary ToShardInfo(this ShardInfoRequest private static Folder ToFolder(this FolderInfoResult.FolderInfoBody.FolderInfoProps item, string publicBaseUrl) { - var folder = new Folder(item.Size, item.Home ?? item.Name, item.Weblink.ToPublicLinkInfos(publicBaseUrl)); + var folder = new Folder(item.Size, item.Home ?? item.Name, item.Weblink.ToPublicLinkInfos(publicBaseUrl)) + { + ServerFoldersCount = item.Count?.Folders, + ServerFilesCount = item.Count?.Files, + }; return folder; } @@ -216,6 +220,9 @@ public static Folder ToFolder(this FolderInfoResult data, string publicBaseUrl, var folder = new Folder(data.Body.Size, data.Body.Home ?? data.Body.Name, data.Body.Weblink.ToPublicLinkInfos(publicBaseUrl)) { + ServerFoldersCount = data.Body.Count?.Folders, + ServerFilesCount = data.Body.Count?.Files, + Folders = data.Body.List? .Where(it => FolderKinds.Contains(it.Kind)) .Select(item => item.ToFolder(publicBaseUrl)) diff --git a/MailRuCloud/MailRuCloudApi/Base/Repos/MailRuCloud/WebBin/WebBinRequestRepo.cs b/MailRuCloud/MailRuCloudApi/Base/Repos/MailRuCloud/WebBin/WebBinRequestRepo.cs index 50bbed0e..bff0359d 100644 --- a/MailRuCloud/MailRuCloudApi/Base/Repos/MailRuCloud/WebBin/WebBinRequestRepo.cs +++ b/MailRuCloud/MailRuCloudApi/Base/Repos/MailRuCloud/WebBin/WebBinRequestRepo.cs @@ -297,7 +297,7 @@ public async Task FolderInfo(RemotePath path, int offset = 0, int limit return await AnonymousRepo.FolderInfo(path, offset, limit); if (!path.IsLink && depth > 1) - return await FolderInfo(path, depth); + return await FolderInfo(path.Path, depth); FolderInfoResult datares; try diff --git a/MailRuCloud/MailRuCloudApi/Base/Requests/Types/FolderInfoResult.cs b/MailRuCloud/MailRuCloudApi/Base/Requests/Types/FolderInfoResult.cs index 9b17d385..003c28a3 100644 --- a/MailRuCloud/MailRuCloudApi/Base/Requests/Types/FolderInfoResult.cs +++ b/MailRuCloud/MailRuCloudApi/Base/Requests/Types/FolderInfoResult.cs @@ -8,8 +8,8 @@ public class FolderInfoResult : CommonOperationResultnetcoreapp3.0;net461 YaR.Clouds YaR.Clouds - 1.11.0.14 - 1.11.0.14 + 1.11.0.15 + 1.11.0.15 8.0 diff --git a/WDMRC.Console/CommandLineOptions.cs b/WDMRC.Console/CommandLineOptions.cs index 7290c15a..17063267 100644 --- a/WDMRC.Console/CommandLineOptions.cs +++ b/WDMRC.Console/CommandLineOptions.cs @@ -54,5 +54,8 @@ class CommandLineOptions public string ProxyUser { get; set; } [Option("proxy-password", Default = "", HelpText = "Proxy password")] public string ProxyPassword { get; set; } + + [Option("use-locks", Required = false, Default = false, HelpText = "locking feature")] + public bool UseLocks { get; set; } } } diff --git a/WDMRC.Console/Payload.cs b/WDMRC.Console/Payload.cs index cf45f316..786275f7 100644 --- a/WDMRC.Console/Payload.cs +++ b/WDMRC.Console/Payload.cs @@ -8,6 +8,7 @@ using NWebDav.Server; using NWebDav.Server.Http; using NWebDav.Server.HttpListener; +using NWebDav.Server.Locking; using NWebDav.Server.Logging; using YaR.Clouds.WebDavStore; using YaR.Clouds.WebDavStore.StoreBase; @@ -46,6 +47,7 @@ public static void Run(CommandLineOptions options) ListDepth = options.CacheListingDepth, AdditionalSpecialCommandPrefix = Config.AdditionalSpecialCommandPrefix, DefaultSharedVideoResolution = Config.DefaultSharedVideoResolution, + UseLocks = options.UseLocks, Proxy = new ProxyFabric().Get(options.ProxyAddress, options.ProxyUser, options.ProxyPassword) }; @@ -101,7 +103,9 @@ private static async Task DispatchHttpRequestsAsync(HttpListener httpListener, i var requestHandlerFactory = new RequestHandlerFactory(); // Create WebDAV dispatcher - var homeFolder = new LocalStore(isEnabledPropFunc: Config.IsEnabledWebDAVProperty); + var homeFolder = new LocalStore( + isEnabledPropFunc: Config.IsEnabledWebDAVProperty, + lockingManager: CloudManager.Settings.UseLocks ? (ILockingManager)new InMemoryLockingManager() : new EmptyLockingManager()); var webDavDispatcher = new WebDavDispatcher(homeFolder, requestHandlerFactory); try diff --git a/WDMRC.Console/WDMRC.Console.csproj b/WDMRC.Console/WDMRC.Console.csproj index 439fba03..12201860 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.11.0.14 - 1.11.0.14 + 1.11.0.15 + 1.11.0.15 wdmrc YaR.Clouds.Console diff --git a/WDMRC.Console/wdmrc.config b/WDMRC.Console/wdmrc.config index 0ccbc9b5..75eeab5f 100644 --- a/WDMRC.Console/wdmrc.config +++ b/WDMRC.Console/wdmrc.config @@ -94,7 +94,7 @@ - + diff --git a/WebDavMailRuCloudStore/CustomProperties/DavSharedLink.cs b/WebDavMailRuCloudStore/CustomProperties/DavSharedLink.cs index 21e004a1..a86a3c90 100644 --- a/WebDavMailRuCloudStore/CustomProperties/DavSharedLink.cs +++ b/WebDavMailRuCloudStore/CustomProperties/DavSharedLink.cs @@ -1,5 +1,4 @@ using System.Xml.Linq; -using NWebDav.Server; using NWebDav.Server.Props; using NWebDav.Server.Stores; @@ -7,7 +6,7 @@ namespace YaR.Clouds.WebDavStore.CustomProperties { public class DavSharedLink : DavString where TEntry : IStoreItem { - private static readonly XName PropertyName = WebDavNamespaces.DavNs + "SharedLink"; + private static readonly XName PropertyName = YarWebDavNamespaces.YarNs + "SharedLink"; public override XName Name => PropertyName; } diff --git a/WebDavMailRuCloudStore/CustomProperties/YarWebDavNamespaces.cs b/WebDavMailRuCloudStore/CustomProperties/YarWebDavNamespaces.cs new file mode 100644 index 00000000..47c34bfc --- /dev/null +++ b/WebDavMailRuCloudStore/CustomProperties/YarWebDavNamespaces.cs @@ -0,0 +1,9 @@ +using System.Xml.Linq; + +namespace YaR.Clouds.WebDavStore.CustomProperties +{ + public static class YarWebDavNamespaces + { + public static readonly XNamespace YarNs = "urn:schemas-yar-now-im:"; + } +} \ No newline at end of file diff --git a/WebDavMailRuCloudStore/StoreBase/LocalStore.cs b/WebDavMailRuCloudStore/StoreBase/LocalStore.cs index 669845b5..b8bad95d 100644 --- a/WebDavMailRuCloudStore/StoreBase/LocalStore.cs +++ b/WebDavMailRuCloudStore/StoreBase/LocalStore.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Net; using System.Threading.Tasks; using NWebDav.Server; @@ -8,7 +7,6 @@ using NWebDav.Server.Props; using NWebDav.Server.Stores; using YaR.Clouds.Base; -using YaR.Clouds.WebDavStore.CustomProperties; namespace YaR.Clouds.WebDavStore.StoreBase { diff --git a/WebDavMailRuCloudStore/StoreBase/LocalStoreCollectionProps.cs b/WebDavMailRuCloudStore/StoreBase/LocalStoreCollectionProps.cs index 59a2c70f..6701635b 100644 --- a/WebDavMailRuCloudStore/StoreBase/LocalStoreCollectionProps.cs +++ b/WebDavMailRuCloudStore/StoreBase/LocalStoreCollectionProps.cs @@ -125,7 +125,13 @@ public LocalStoreCollectionProps(Func isEnabledPropFunc) //Hopmann/Lippert collection properties new DavExtCollectionChildCount { - Getter = (cntext, collection) => collection.DirectoryInfo.NumberOfFolders + collection.DirectoryInfo.NumberOfFiles + Getter = (cntext, collection) => + { + int files = collection.DirectoryInfo.NumberOfFiles; + int folders = collection.DirectoryInfo.NumberOfFolders; + return folders > 0 ? folders : collection.DirectoryInfo.ServerFoldersCount + + files > 0 ? files : collection.DirectoryInfo.ServerFilesCount ?? 0; + } }, new DavExtCollectionIsFolder { @@ -140,19 +146,22 @@ public LocalStoreCollectionProps(Func isEnabledPropFunc) Getter = (cntext, collection) => false }, - new DavExtCollectionHasSubs + new DavExtCollectionHasSubs //Identifies whether this collection contains any collections which are folders (see "isfolder"). { - Getter = (cntext, collection) => collection.DirectoryInfo.NumberOfFolders > 0 + Getter = (cntext, collection) => collection.DirectoryInfo.NumberOfFolders > 0 || collection.DirectoryInfo.ServerFoldersCount > 0 }, - new DavExtCollectionNoSubs + new DavExtCollectionNoSubs //Identifies whether this collection allows child collections to be created. { Getter = (cntext, collection) => false }, - new DavExtCollectionObjectCount + new DavExtCollectionObjectCount //To count the number of non-folder resources in the collection. { - Getter = (cntext, collection) => collection.DirectoryInfo.NumberOfFiles + Getter = (cntext, collection) => + collection.DirectoryInfo.NumberOfFiles > 0 + ? collection.DirectoryInfo.NumberOfFiles + : collection.DirectoryInfo.ServerFilesCount ?? 0 }, new DavExtCollectionReserved @@ -160,9 +169,12 @@ public LocalStoreCollectionProps(Func isEnabledPropFunc) Getter = (cntext, collection) => !collection.IsWritable }, - new DavExtCollectionVisibleCount + new DavExtCollectionVisibleCount //Counts the number of visible non-folder resources in the collection. { - Getter = (cntext, collection) => collection.DirectoryInfo.NumberOfFiles + collection.DirectoryInfo.NumberOfFolders + Getter = (cntext, collection) => + collection.DirectoryInfo.NumberOfFiles > 0 + ? collection.DirectoryInfo.NumberOfFiles + : collection.DirectoryInfo.ServerFilesCount ?? 0 }, // Win32 extensions diff --git a/readme.md b/readme.md index 67a14b7c..ae48712d 100644 --- a/readme.md +++ b/readme.md @@ -19,6 +19,7 @@ -p, --port (Default: 801) WebDAV server port or several ports separated by `,` -h, --host (Default: "http://127.0.0.1") WebDAV server host with protocol (http://* for http://0.0.0.0) --maxthreads (Default: 5) Maximum concurrent connections to cloud.mail.ru + --use-locks (Default: false) locking feature --cache-listing (Default: 30) Cache folders listing, sec --cache-listing-depth (Default: 1) Cache folders listing depth. If large folder browsing is extremely slow, set to 2