Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin work on migrating NWebDav #79

Draft
wants to merge 3 commits into
base: f_qa
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,15 @@ internal sealed partial class SkiaWebDavFileSystem
#if HAS_UNO_SKIA && !__MACCATALYST__
/// <inheritdoc/>
protected override async Task<IVFSRoot> MountAsync(
int port,
string domain,
string protocol,
HttpListener listener,
FileSystemOptions options,
IRequestDispatcher requestDispatcher,
WebDavOptions options,
IAsyncDisposable webDavInstance,
CancellationToken cancellationToken)
{
var remotePath = DriveMappingHelpers.GetRemotePath(protocol, "localhost", port, options.VolumeName);
var remotePath = DriveMappingHelpers.GetRemotePath(options.Protocol, options.Domain, options.Port, options.VolumeName);
var mountPath = await DriveMappingHelpers.GetMountPathForRemotePathAsync(remotePath);

var webDavWrapper = new WebDavWrapper(listener, requestDispatcher, mountPath);
webDavWrapper.StartFileSystem();

// TODO: Remove once the port is displayed in the UI.
Debug.WriteLine($"WebDAV server started on port {port}.");
Debug.WriteLine($"MountableDAV\nmountPath: {mountPath}\nremotePath: {remotePath}");

// TODO: Currently using MemoryFolder because the check in SystemFolder might sometimes fail
return new WebDavRootFolder(webDavWrapper, new MemoryFolder(remotePath, options.VolumeName), options);
return new WebDavRootFolder(webDavInstance, new MemoryFolder(remotePath, options.VolumeName), options);
}
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using NWebDav.Server.Dispatching;
using SecureFolderFS.Core.WebDav;
using SecureFolderFS.Core.WebDav.AppModels;
using SecureFolderFS.Storage.VirtualFileSystem;
Expand All @@ -20,9 +19,8 @@ namespace SecureFolderFS.Uno.Platforms.Desktop
internal sealed partial class MacOsWebDavFileSystem : WebDavFileSystem
{
protected override async Task<IVFSRoot> MountAsync(
HttpListener listener,
WebDavOptions options,
IRequestDispatcher requestDispatcher,
IAsyncDisposable webDavInstance,
CancellationToken cancellationToken)
{
#if __MACCATALYST__
Expand All @@ -32,14 +30,9 @@ protected override async Task<IVFSRoot> MountAsync(
// Mount WebDAV volume via AppleScript
Process.Start("/usr/bin/osascript", ["-e", $"mount volume \"{remoteUri.AbsoluteUri}\""]);
var mountPoint = $"/Volumes/{options.VolumeName}";

// Create wrapper
var webDavWrapper = new WebDavWrapper(listener, requestDispatcher, mountPoint);
webDavWrapper.StartFileSystem();

Debug.WriteLine($"Mounted {remoteUri} on {mountPoint}.");
await Task.CompletedTask;
return new WebDavRootFolder(webDavWrapper, new MemoryFolder(mountPoint, options.VolumeName), options);
return new WebDavRootFolder(webDavInstance, new MemoryFolder(mountPoint, options.VolumeName), options);
#else
throw new PlatformNotSupportedException();
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Diagnostics;
using System;
using System.IO;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using NWebDav.Server.Dispatching;
using OwlCore.Storage.Memory;
using SecureFolderFS.Core.FileSystem.Helpers;
using SecureFolderFS.Core.WebDav;
Expand All @@ -18,12 +16,11 @@ public sealed class WindowsWebDavFileSystem : WebDavFileSystem
{
/// <inheritdoc/>
protected override async Task<IVFSRoot> MountAsync(
HttpListener listener,
WebDavOptions options,
IRequestDispatcher requestDispatcher,
IAsyncDisposable webDavInstance,
CancellationToken cancellationToken)
{
var remotePath = DriveMappingHelpers.GetRemotePath(options.Protocol, "localhost", options.Port, options.VolumeName);
var remotePath = DriveMappingHelpers.GetRemotePath(options.Protocol, options.Domain, options.Port, options.VolumeName);
var mountPath = await DriveMappingHelpers.GetMountPathForRemotePathAsync(remotePath);
if (mountPath is null)
{
Expand All @@ -34,14 +31,7 @@ protected override async Task<IVFSRoot> MountAsync(
await DriveMappingHelpers.MapNetworkDriveAsync(mountPath, remotePath, cancellationToken);
}

var webDavWrapper = new WebDavWrapper(listener, requestDispatcher, mountPath);
webDavWrapper.StartFileSystem();

// TODO: Remove once the port is displayed in the UI.
Debug.WriteLine($"WebDAV server started on port {options.Port}.");

// TODO: Currently using MemoryFolder because the check in SystemFolder might sometimes fail
return new WindowsWebDavVFSRoot(webDavWrapper, new MemoryFolder(remotePath, options.VolumeName), options);
return new WindowsWebDavVFSRoot(webDavInstance, new MemoryFolder(remotePath, options.VolumeName), options);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Threading.Tasks;
using OwlCore.Storage;
using SecureFolderFS.Core.FileSystem;
using SecureFolderFS.Core.WebDav;
using SecureFolderFS.Storage.VirtualFileSystem;
using SecureFolderFS.Core.WebDav;

#if WINDOWS
using System;
Expand All @@ -15,39 +14,27 @@
namespace SecureFolderFS.Uno.Platforms.Windows
{
/// <inheritdoc cref="IVFSRoot"/>
internal sealed class WindowsWebDavVFSRoot : VFSRoot
internal sealed class WindowsWebDavVFSRoot : WebDavRootFolder
{
private const uint WM_CLOSE = 0x0010;

private readonly WebDavWrapper _webDavWrapper;
private bool _disposed;

/// <inheritdoc/>
public override string FileSystemName { get; } = Core.WebDav.Constants.FileSystem.FS_NAME;

public WindowsWebDavVFSRoot(WebDavWrapper webDavWrapper, IFolder storageRoot, FileSystemOptions options)
: base(storageRoot, options)
public WindowsWebDavVFSRoot(IAsyncDisposable webDavInstance, IFolder storageRoot, FileSystemOptions options)
: base(webDavInstance, storageRoot, options)
{
_webDavWrapper = webDavWrapper;
}

/// <inheritdoc/>
public override async ValueTask DisposeAsync()
protected override async ValueTask DisposeInternalAsync()
{
if (_disposed)
return;
await base.DisposeInternalAsync();

_disposed = await _webDavWrapper.CloseFileSystemAsync();
if (_disposed)
{
FileSystemManager.Instance.RemoveRoot(this);
await CloseExplorerShellAsync(Inner.Id);
}
// Close the shell on Windows
await CloseExplorerShellAsync(Inner.Id);
}

private static async Task CloseExplorerShellAsync(string path)
{
#if WINDOWS
const uint WM_CLOSE = 0x0010;

try
{
var formattedPath = PathHelpers.EnsureNoTrailingPathSeparator(path);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using SecureFolderFS.Core.FileSystem;

namespace SecureFolderFS.Core.WebDav.AppModels
{
internal sealed class CipherStoreOptions
{
public FileSystemSpecifics? Specifics { get; set; }
}
}

This file was deleted.

Loading