In fixed-size chunking, create a new chunk after returning the old one

This commit is contained in:
Gilbert Chen
2017-06-29 13:11:28 -04:00
parent d27335ad8d
commit 42a6ab9140
3 changed files with 20 additions and 2 deletions

18
integration_tests/fixed_test.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Sanity test for the fixed-size chunking algorithm
. ./test_functions.sh
fixture
pushd ${TEST_REPO}
${DUPLICACY} init integration-tests $TEST_STORAGE -c 64 -max 64 -min 64
add_file file3
add_file file4
${DUPLICACY} backup
${DUPLICACY} check --files -stats
popd

View File

@@ -1132,7 +1132,7 @@ func (manager *BackupManager) RestoreFile(chunkDownloader *ChunkDownloader, chun
fileHash = hash fileHash = hash
return nil, false return nil, false
}) })
if fileHash == entry.Hash { if fileHash == entry.Hash && fileHash != "" {
LOG_TRACE("DOWNLOAD_SKIP", "File %s unchanged (by hash)", entry.Path) LOG_TRACE("DOWNLOAD_SKIP", "File %s unchanged (by hash)", entry.Path)
return false return false
} }

View File

@@ -146,7 +146,6 @@ func (maker *ChunkMaker) ForEachChunk(reader io.Reader, endOfChunk func(chunk *C
} }
for { for {
startNewChunk()
maker.bufferStart = 0 maker.bufferStart = 0
for maker.bufferStart < maker.minimumChunkSize && !isEOF { for maker.bufferStart < maker.minimumChunkSize && !isEOF {
count, err := reader.Read(maker.buffer[maker.bufferStart : maker.minimumChunkSize]) count, err := reader.Read(maker.buffer[maker.bufferStart : maker.minimumChunkSize])
@@ -174,6 +173,7 @@ func (maker *ChunkMaker) ForEachChunk(reader io.Reader, endOfChunk func(chunk *C
return return
} else { } else {
endOfChunk(chunk, false) endOfChunk(chunk, false)
startNewChunk()
fileSize = 0 fileSize = 0
fileHasher = maker.config.NewFileHasher() fileHasher = maker.config.NewFileHasher()
isEOF = false isEOF = false