Beispiel #1
0
 /// <inheritdoc />
 public override void Initialize()
 {
     _chunkHasher.Initialize();
     _chunks.Clear();
     _session?.Dispose();
     _session         = null;
     _sizeHint        = -1;
     _chunkingStarted = false;
     _bytesChunked    = 0;
 }
        /// <inheritdoc />
        protected override byte[] HashFinal()
        {
            _session.Dispose();

            if (_chunker.TotalBytes == 0)
            {
                _chunks.Add(new ChunkInfo(0, 0, DedupChunkHashInfo.Instance.EmptyHash.ToHashByteArray()));
            }

            _lastNode = DedupNodeTree.Create(_chunks, _treeAlgorithm);

            // The array returned by this function will be cleared when this is disposed, so clone it.
            return(_lastNode.Value.Hash.ToArray());
        }
        /// <inheritdoc />
        /// <remarks>
        /// Extends DedupNode algorithm to tag hash as DedupChunk or DedupNode.
        /// </remarks>
        protected override byte[] HashFinal()
        {
            _session.Dispose();

            if (_chunker.TotalBytes == 0)
            {
                _chunks.Add(new ChunkInfo(0, 0, DedupChunkHashInfo.Instance.EmptyHash.ToHashByteArray()));
            }

            _lastNode = DedupNodeTree.Create(_chunks, _treeAlgorithm);

            if (_lastNode.Value.ChildNodes.Count == 1)
            {
                // Content is small enough to track as a chunk.
                _lastNode = _lastNode.Value.ChildNodes.Single();
            }

            return(SerializeHashAndId());
        }
Beispiel #4
0
        /// <inheritdoc />
        /// <remarks>
        /// Extends DedupNode algorithm to tag hash as DedupChunk or DedupNode.
        /// </remarks>
        protected override byte[] HashFinal()
        {
            _session.Dispose();

            if (_chunks.Count == 0)
            {
                _chunks.Add(new ChunkInfo(0, 0, DedupChunkHashInfo.Instance.EmptyHash.ToHashByteArray()));
            }

            if (_chunks.Count == 1)
            {
                // Content is small enough to track as a chunk.
                _lastNode = new DedupNode(_chunks.Single());
                Contract.Assert(_lastNode.Value.Type == DedupNode.NodeType.ChunkLeaf);
            }
            else
            {
                _lastNode = DedupNodeTree.Create(_chunks, _treeAlgorithm);
            }

            return(SerializeHashAndId());
        }