Ejemplo n.º 1
0
        private async Task <Stream> UpdateCachedFile(string fileName, byte[] cachedFileContent, ServerServiceClient serverServiceClient, string cachedFileLocation)
        {
            List <Chunk> cachedChunks = RabinKarpAlgorithm.Slice(cachedFileContent);

            DifferenceChunkDto[] differenceChunkDtos = await serverServiceClient.GetUpdatedChunksAsync(fileName, cachedChunks.Select(CachedChunkDtoMapper.Map).ToArray());

            byte[] newFileContent = ConstructContentOfTheUpdateFile(differenceChunkDtos, cachedChunks, fileName);
            System.IO.File.WriteAllBytes(cachedFileLocation, newFileContent);
            return(new MemoryStream(newFileContent));
        }