Smb save servers, auth

This commit is contained in:
2022-02-10 11:24:04 +01:00
parent 70180b9f12
commit ec03067af1
19 changed files with 463 additions and 132 deletions

View File

@@ -11,7 +11,7 @@ namespace FileTime.Providers.Smb
private IReadOnlyList<IItem>? _items;
private IReadOnlyList<IContainer>? _containers;
private IReadOnlyList<IElement>? _elements;
private SmbClientContext _smbClientContext;
private readonly SmbClientContext _smbClientContext;
private readonly IContainer? _parent;
public string Name { get; }
@@ -45,17 +45,17 @@ namespace FileTime.Providers.Smb
public async Task<IReadOnlyList<IItem>?> GetItems(CancellationToken token = default)
{
if (_items == null) await RefreshAsync();
if (_items == null) await RefreshAsync(token);
return _items;
}
public async Task<IReadOnlyList<IContainer>?> GetContainers(CancellationToken token = default)
{
if (_containers == null) await RefreshAsync();
if (_containers == null) await RefreshAsync(token);
return _containers;
}
public async Task<IReadOnlyList<IElement>?> GetElements(CancellationToken token = default)
{
if (_elements == null) await RefreshAsync();
if (_elements == null) await RefreshAsync(token);
return _elements;
}
@@ -74,25 +74,6 @@ namespace FileTime.Providers.Smb
throw new NotImplementedException();
}
public async Task<IItem?> GetByPath(string path, bool acceptDeepestMatch = false)
{
var paths = path.Split(Constants.SeparatorChar);
var item = (await GetItems())?.FirstOrDefault(i => i.Name == paths[0]);
if (paths.Length == 1)
{
return item;
}
if (item is IContainer container)
{
return await container.GetByPath(string.Join(Constants.SeparatorChar, paths.Skip(1)), acceptDeepestMatch);
}
return null;
}
public IContainer? GetParent() => _parent;
public Task<IContainer> Clone() => Task.FromResult((IContainer)this);