public static async Task <VirtualDiskIncrement> CreateNewAsync(
            VirtualDisk vd,
            IBackupLocationFactory sourceLocationFactory,
            IBackupLocationFactory targetLocationFactory,
            string targetLocation,
            int incrementSize,
            HashSet <string> existingChunkHashes
            )
        {
            VirtualDiskIncrement increment = new VirtualDiskIncrement();
            Stream sourceStream            = sourceLocationFactory.Open(vd);

            byte[] buffer     = new byte[incrementSize];
            int    chunkIndex = 0;

            while (sourceStream.Position < sourceStream.Length)
            {
                long remainingBytes = sourceStream.Length - sourceStream.Position;
                if (remainingBytes < buffer.Length)
                {
                    buffer = new byte[remainingBytes];
                }
                await increment.SaveVirtualDiskChunkAsync(sourceStream, chunkIndex, existingChunkHashes, targetLocationFactory, targetLocation, buffer);

                chunkIndex++;
            }
            return(increment);
        }
Esempio n. 2
0
 public void AddIncrement(VirtualDiskIncrement increment)
 {
     if (OriginalIncrement == null)
     {
         OriginalIncrement = increment;
     }
     else
     {
         _increments.Add(increment);
     }
 }