Exemplo n.º 1
0
        private static ChunksData ConvertToChunksData(Api.Models.Main.Chunks chunks)
        {
            if (chunks.Size == 0 || chunks.Hashes == null)
            {
                return(new ChunksData
                {
                    ChunkSize = 0,
                    Chunks = new Chunk[] {}
                });
            }

            var chunksData = new ChunksData
            {
                ChunkSize = chunks.Size,
                Chunks    = new Chunk[chunks.Hashes.Length]
            };

            for (int index = 0; index < chunks.Hashes.Length; index++)
            {
                string hash  = chunks.Hashes[index];
                var    array = XXHashToByteArray(hash);

                chunksData.Chunks[index] = new Chunk
                {
                    Hash = array
                };
            }
            return(chunksData);
        }
 private static IChunkedHttpDownloader CreateDefaultChunkedHttpDownloader([NotNull] string destinationFilePath,
                                                                          [NotNull] ResourceUrl[] urls, ChunksData chunksData,
                                                                          long size)
 {
     return(new ChunkedHttpDownloader(destinationFilePath, urls, chunksData, size));
 }