mirror of
https://github.com/kopia/kopia.git
synced 2026-03-28 02:53:05 -04:00
small compaction fix
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
"reflect"
|
||||
"runtime/debug"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kopia/kopia/auth"
|
||||
|
||||
@@ -190,6 +191,30 @@ func TestPackingSimple(t *testing.T) {
|
||||
verify(t, repo, oid1a, []byte(content1), "packed-object-1")
|
||||
verify(t, repo, oid2a, []byte(content2), "packed-object-2")
|
||||
verify(t, repo, oid3a, []byte(content3), "packed-object-3")
|
||||
|
||||
if err := repo.Optimize(time.Now().Add(10 * time.Second)); err != nil {
|
||||
t.Errorf("optimize error: %v", err)
|
||||
}
|
||||
data, repo = setupTestWithData(t, data, func(n *NewRepositoryOptions) {
|
||||
n.MaxPackFileLength = 10000
|
||||
n.MaxPackedContentLength = 10000
|
||||
})
|
||||
|
||||
verify(t, repo, oid1a, []byte(content1), "packed-object-1")
|
||||
verify(t, repo, oid2a, []byte(content2), "packed-object-2")
|
||||
verify(t, repo, oid3a, []byte(content3), "packed-object-3")
|
||||
|
||||
if err := repo.Optimize(time.Now().Add(-10 * time.Second)); err != nil {
|
||||
t.Errorf("optimize error: %v", err)
|
||||
}
|
||||
data, repo = setupTestWithData(t, data, func(n *NewRepositoryOptions) {
|
||||
n.MaxPackFileLength = 10000
|
||||
n.MaxPackedContentLength = 10000
|
||||
})
|
||||
|
||||
verify(t, repo, oid1a, []byte(content1), "packed-object-1")
|
||||
verify(t, repo, oid2a, []byte(content2), "packed-object-2")
|
||||
verify(t, repo, oid3a, []byte(content3), "packed-object-3")
|
||||
}
|
||||
|
||||
func verifyIndirectBlock(t *testing.T, r *Repository, oid ObjectID) {
|
||||
|
||||
@@ -345,7 +345,7 @@ func (p *packManager) Compact(cutoffTime time.Time) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(blockIDs) < parallelFetches {
|
||||
if len(blockIDs) <= 1 {
|
||||
log.Printf("skipping index compaction - the number of segments %v is too low", len(blockIDs))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user