Skip to content

Commit

Permalink
Merge branch 'develop2'
Browse files Browse the repository at this point in the history
  • Loading branch information
yar229 committed Feb 2, 2020
2 parents 74dfb31 + 4e918e7 commit d07d784
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 25 deletions.
6 changes: 5 additions & 1 deletion MailRuCloud/MailRuCloudApi/Base/Folder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ public IEnumerable<PublicLinkInfo> 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ public static Dictionary<ShardType, ShardInfo> 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;
}

Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public async Task<IEntry> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class FolderInfoResult : CommonOperationResult<FolderInfoResult.FolderInf
{
public class FolderInfoBody
{
//[JsonProperty("count")]
//public FolderInfoCount Count { get; set; }
[JsonProperty("count")]
public FolderInfoCount Count { get; set; }

//[JsonProperty("tree")]
//public string Tree { get; set; }
Expand Down Expand Up @@ -49,8 +49,8 @@ public class FolderInfoProps
[JsonProperty("mtime")]
public ulong Mtime;

//[JsonProperty("count")]
//public FolderInfoCount Count { get; set; }
[JsonProperty("count")]
public FolderInfoCount Count { get; set; }

//[JsonProperty("tree")]
//public string Tree { get; set; }
Expand Down
1 change: 1 addition & 0 deletions MailRuCloud/MailRuCloudApi/CloudSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ public int ListDepth

public SharedVideoResolution DefaultSharedVideoResolution { get; set; } = SharedVideoResolution.All;
public IWebProxy Proxy { get; set; }
public bool UseLocks { get; set; }
}
}
4 changes: 2 additions & 2 deletions MailRuCloud/MailRuCloudApi/YaR.Clouds.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks>
<RootNamespace>YaR.Clouds</RootNamespace>
<AssemblyName>YaR.Clouds</AssemblyName>
<AssemblyVersion>1.11.0.14</AssemblyVersion>
<FileVersion>1.11.0.14</FileVersion>
<AssemblyVersion>1.11.0.15</AssemblyVersion>
<FileVersion>1.11.0.15</FileVersion>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

Expand Down
3 changes: 3 additions & 0 deletions WDMRC.Console/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
6 changes: 5 additions & 1 deletion WDMRC.Console/Payload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
};
Expand Down Expand Up @@ -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
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.11.0.14</AssemblyVersion>
<FileVersion>1.11.0.14</FileVersion>
<AssemblyVersion>1.11.0.15</AssemblyVersion>
<FileVersion>1.11.0.15</FileVersion>
<AssemblyName>wdmrc</AssemblyName>
<RootNamespace>YaR.Clouds.Console</RootNamespace>
<StartupObject></StartupObject>
Expand Down
2 changes: 1 addition & 1 deletion WDMRC.Console/wdmrc.config
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<Prop name="{urn:schemas-microsoft-com:}Win32LastModifiedTime" enabled="true" />
<Prop name="{urn:schemas-microsoft-com:}Win32FileAttributes" enabled="true" />

<Prop name="{DAV:}SharedLink" enabled="true" />
<Prop name="{urn:schemas-yar-now-im:}SharedLink" enabled="false" />
</WebDAVProps>


Expand Down
3 changes: 1 addition & 2 deletions WebDavMailRuCloudStore/CustomProperties/DavSharedLink.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System.Xml.Linq;
using NWebDav.Server;
using NWebDav.Server.Props;
using NWebDav.Server.Stores;

namespace YaR.Clouds.WebDavStore.CustomProperties
{
public class DavSharedLink<TEntry> : DavString<TEntry> where TEntry : IStoreItem
{
private static readonly XName PropertyName = WebDavNamespaces.DavNs + "SharedLink";
private static readonly XName PropertyName = YarWebDavNamespaces.YarNs + "SharedLink";

public override XName Name => PropertyName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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:";
}
}
2 changes: 0 additions & 2 deletions WebDavMailRuCloudStore/StoreBase/LocalStore.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using NWebDav.Server;
Expand All @@ -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
{
Expand Down
28 changes: 20 additions & 8 deletions WebDavMailRuCloudStore/StoreBase/LocalStoreCollectionProps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ public LocalStoreCollectionProps(Func<string, bool> isEnabledPropFunc)
//Hopmann/Lippert collection properties
new DavExtCollectionChildCount<T>
{
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<T>
{
Expand All @@ -140,29 +146,35 @@ public LocalStoreCollectionProps(Func<string, bool> isEnabledPropFunc)
Getter = (cntext, collection) => false
},

new DavExtCollectionHasSubs<T>
new DavExtCollectionHasSubs<T> //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<T>
new DavExtCollectionNoSubs<T> //Identifies whether this collection allows child collections to be created.
{
Getter = (cntext, collection) => false
},

new DavExtCollectionObjectCount<T>
new DavExtCollectionObjectCount<T> //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<T>
{
Getter = (cntext, collection) => !collection.IsWritable
},

new DavExtCollectionVisibleCount<T>
new DavExtCollectionVisibleCount<T> //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
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d07d784

Please sign in to comment.