ContentProvider more async
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using FileTime.Providers.LocalAdmin;
|
||||
using FileTime.Providers.Remote;
|
||||
using FileTime.Server.Common;
|
||||
|
||||
namespace FileTime.Server.App;
|
||||
|
||||
|
||||
@@ -13,4 +13,5 @@ public interface IRemoteConnection
|
||||
Task WriteBytesAsync(string transactionId, byte[] data, int? index, CancellationToken cancellationToken = default);
|
||||
Task FlushWriterAsync(string transactionId, CancellationToken cancellationToken = default);
|
||||
Task CloseWriterAsync(string transactionId);
|
||||
Task<NativePath?> GetNativePathAsync(FullName fullName);
|
||||
}
|
||||
@@ -15,4 +15,5 @@ public interface ISignalRHub
|
||||
//TODO: CancellationToken https://github.com/nenoNaninu/TypedSignalR.Client/issues/120
|
||||
Task WriteBytesAsync(string transactionId, string data, int index);
|
||||
Task CloseWriterAsync(string transactionId);
|
||||
Task<string?> GetNativePathAsync(string fullNamePath);
|
||||
}
|
||||
@@ -77,4 +77,10 @@ public class SignalRConnection : IRemoteConnection, IAsyncInitable<string>
|
||||
|
||||
public async Task CloseWriterAsync(string transactionId)
|
||||
=> await _client.CloseWriterAsync(transactionId);
|
||||
|
||||
public async Task<NativePath?> GetNativePathAsync(FullName fullName)
|
||||
{
|
||||
var path = await _client.GetNativePathAsync(fullName.Path);
|
||||
return path is null ? null : new NativePath(path);
|
||||
}
|
||||
}
|
||||
@@ -14,17 +14,20 @@ public class ConnectionHub : Hub<ISignalRClient>, ISignalRHub
|
||||
private readonly IContentAccessorFactory _contentAccessorFactory;
|
||||
private readonly IApplicationStopper _applicationStopper;
|
||||
private readonly IContentAccessManager _contentAccessManager;
|
||||
private readonly ITimelessContentProvider _timelessContentProvider;
|
||||
|
||||
public ConnectionHub(
|
||||
IContentProviderRegistry contentProviderRegistry,
|
||||
IContentAccessorFactory contentAccessorFactory,
|
||||
IApplicationStopper applicationStopper,
|
||||
IContentAccessManager contentAccessManager)
|
||||
IContentAccessManager contentAccessManager,
|
||||
ITimelessContentProvider timelessContentProvider)
|
||||
{
|
||||
_contentProviderRegistry = contentProviderRegistry;
|
||||
_contentAccessorFactory = contentAccessorFactory;
|
||||
_applicationStopper = applicationStopper;
|
||||
_contentAccessManager = contentAccessManager;
|
||||
_timelessContentProvider = timelessContentProvider;
|
||||
}
|
||||
|
||||
public Task Exit()
|
||||
@@ -86,4 +89,7 @@ public class ConnectionHub : Hub<ISignalRClient>, ISignalRHub
|
||||
_contentAccessManager.RemoveContentWriter(transactionId);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task<string?> GetNativePathAsync(string fullNamePath)
|
||||
=> (await _timelessContentProvider.GetNativePathByFullNameAsync(new FullName(fullNamePath)))?.Path;
|
||||
}
|
||||
Reference in New Issue
Block a user