private string[] FetchMd5Sums(IAsyncFilesCommands filesCommands, int filesCount = 2) { return(Enumerable.Range(1, filesCount).Select(i => { var meta = filesCommands.GetMetadataForAsync(string.Format("file{0}.bin", i)).Result; return meta.Value <string>("Content-MD5"); }).ToArray()); }
protected void WaitForFile(IAsyncFilesCommands filesCommands, string fileName) { var done = SpinWait.SpinUntil(() => { var file = filesCommands.GetMetadataForAsync(fileName).Result; return(file != null); }, TimeSpan.FromSeconds(15)); if (!done) { throw new Exception("WaitForDocument failed"); } }
private static async Task <string> ExecuteRawSynchronizationRequest(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("destination"))); if (action != null) { action(); } await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("source"))); var sourceStream = new MemoryStream(); (await sourceClient.DownloadAsync("test")).CopyTo(sourceStream); var metadata = await sourceClient.GetMetadataForAsync("test"); var request = new SynchronizationMultipartRequest(destinationClient.Synchronization, new ServerInfo() { FileSystemUrl = sourceClient.UrlFor(), Id = sourceClient.GetServerIdAsync().Result }, "test", metadata, sourceStream, new[] { new RdcNeed() { BlockLength = 6, BlockType = RdcNeedType.Source, FileOffset = 0 } }); var synchronizationReport = await request.PushChangesAsync(CancellationToken.None); Assert.Null(synchronizationReport.Exception); var stream = await destinationClient.DownloadAsync("test"); return(StreamToString(stream)); }
private static async Task<string> ExecuteRawSynchronizationRequest(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("destination"))); if (action != null) action(); await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("source"))); var sourceStream = new MemoryStream(); (await sourceClient.DownloadAsync("test")).CopyTo(sourceStream); var metadata = await sourceClient.GetMetadataForAsync("test"); var request = new SynchronizationMultipartRequest(destinationClient.Synchronization, new ServerInfo() { FileSystemUrl = sourceClient.UrlFor(), Id = sourceClient.GetServerIdAsync().Result }, "test", metadata, sourceStream, new[] { new RdcNeed() { BlockLength = 6, BlockType = RdcNeedType.Source, FileOffset = 0 } }); var synchronizationReport = await request.PushChangesAsync(CancellationToken.None); Assert.Null(synchronizationReport.Exception); var stream = await destinationClient.DownloadAsync("test"); return StreamToString(stream); }
private string[] FetchMd5Sums(IAsyncFilesCommands filesCommands, int filesCount = 2) { return Enumerable.Range(1, filesCount).Select(i => { var meta = filesCommands.GetMetadataForAsync(string.Format("file{0}.bin", i)).Result; return meta.Value<string>("Content-MD5"); }).ToArray(); }