FubarDev.FtpServer.FileSystem.OneDrive.OneDriveFileSystem.GetEntryByNameAsync C# (CSharp) Method

GetEntryByNameAsync() public method

public GetEntryByNameAsync ( IUnixDirectoryEntry directoryEntry, string name, CancellationToken cancellationToken ) : Task
directoryEntry IUnixDirectoryEntry
name string
cancellationToken System.Threading.CancellationToken
return Task
        public async Task<IUnixFileSystemEntry> GetEntryByNameAsync(IUnixDirectoryEntry directoryEntry, string name, CancellationToken cancellationToken)
        {
            var item = ((OneDriveDirectoryEntry)directoryEntry).Item;
            var childId = GetFileId(item.Id, name);
            var child = await _cache.TryGet(childId, () => Service.GetChildItemAsync(Drive.Id, item.Id, name, cancellationToken), _defaultCacheTimeSpan);
            if (child == null)
            {
                await _uploadsLock.WaitAsync(cancellationToken);
                try
                {
                    var result = _uploads.Values
                                         .Where(x => x.ParentId == item.Id)
                                         .Select(x => new OneDriveFileEntry(this, x.Item, x.FileSize))
                                         .FirstOrDefault();
                    return result;
                }
                finally
                {
                    _uploadsLock.Release();
                }
            }
            return await ConvertToUnixFileSystemEntry(child, cancellationToken);
        }