From cac8795d33cd52d362e02590b4df4ccd9b96ff71 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Wed, 22 Sep 2021 22:18:29 +0200 Subject: fix mystical bug by making multiple passes We make ne passes while new blocks have been added. This way we are assured that the result will be the same on following runs. result : 161 /tmp/test-1/00001/recipe 161 /tmp/test-1/00001/files 0 /tmp/test-1/00001/hashes 40 /tmp/test-1/00001/chunks 482 /tmp/test-1/00001 9904052 /tmp/test-1/00000/recipe 5377304 /tmp/test-1/00000/files 2061331 /tmp/test-1/00000/hashes 207958371 /tmp/test-1/00000/chunks 225301178 /tmp/test-1/00000 225301740 /tmp/test-1 --- repo_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'repo_test.go') diff --git a/repo_test.go b/repo_test.go index 0ee7bef..52da9ae 100644 --- a/repo_test.go +++ b/repo_test.go @@ -224,7 +224,12 @@ func TestBsdiff(t *testing.T) { newPath := filepath.Join(repo.path, fmt.Sprintf(versionFmt, newVersion)) os.MkdirAll(newPath, 0775) reader := getDataStream(dataDir, concatFiles) - recipe := repo.matchStream(reader, newVersion) + storeQueue := make(chan chunkData, 10) + storeEnd := make(chan bool) + go repo.storageWorker(newVersion, storeQueue, storeEnd) + recipe, _ := repo.matchStream(reader, storeQueue, newVersion, 0) + close(storeQueue) + <-storeEnd newChunks := extractDeltaChunks(recipe) testutils.AssertLen(t, 2, newChunks, "New delta chunks:") for _, c := range newChunks { -- cgit v1.2.3