mirror of
https://github.com/octoleo/restic.git
synced 2024-11-30 00:33:57 +00:00
repository: remove unused (Master)Index.Count
This commit is contained in:
parent
8ef2968f28
commit
e0a7852b8b
@ -314,15 +314,6 @@ func (idx *Index) Packs() restic.IDSet {
|
|||||||
return packs
|
return packs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count returns the number of blobs of type t in the index.
|
|
||||||
func (idx *Index) Count(t restic.BlobType) (n uint) {
|
|
||||||
debug.Log("counting blobs of type %v", t)
|
|
||||||
idx.m.Lock()
|
|
||||||
defer idx.m.Unlock()
|
|
||||||
|
|
||||||
return idx.byType[t].len()
|
|
||||||
}
|
|
||||||
|
|
||||||
type packJSON struct {
|
type packJSON struct {
|
||||||
ID restic.ID `json:"id"`
|
ID restic.ID `json:"id"`
|
||||||
Blobs []blobJSON `json:"blobs"`
|
Blobs []blobJSON `json:"blobs"`
|
||||||
|
@ -158,19 +158,6 @@ func (mi *MasterIndex) Packs(packBlacklist restic.IDSet) restic.IDSet {
|
|||||||
return packs
|
return packs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count returns the number of blobs of type t in the index.
|
|
||||||
func (mi *MasterIndex) Count(t restic.BlobType) (n uint) {
|
|
||||||
mi.idxMutex.RLock()
|
|
||||||
defer mi.idxMutex.RUnlock()
|
|
||||||
|
|
||||||
var sum uint
|
|
||||||
for _, idx := range mi.idx {
|
|
||||||
sum += idx.Count(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
return sum
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert adds a new index to the MasterIndex.
|
// Insert adds a new index to the MasterIndex.
|
||||||
func (mi *MasterIndex) Insert(idx *Index) {
|
func (mi *MasterIndex) Insert(idx *Index) {
|
||||||
mi.idxMutex.Lock()
|
mi.idxMutex.Lock()
|
||||||
|
@ -122,12 +122,6 @@ func TestMasterIndex(t *testing.T) {
|
|||||||
rtest.Assert(t, blobs == nil, "Expected no blobs when fetching with a random id")
|
rtest.Assert(t, blobs == nil, "Expected no blobs when fetching with a random id")
|
||||||
_, found = mIdx.LookupSize(restic.NewRandomBlobHandle())
|
_, found = mIdx.LookupSize(restic.NewRandomBlobHandle())
|
||||||
rtest.Assert(t, !found, "Expected no blobs when fetching with a random id")
|
rtest.Assert(t, !found, "Expected no blobs when fetching with a random id")
|
||||||
|
|
||||||
// Test Count
|
|
||||||
num := mIdx.Count(restic.DataBlob)
|
|
||||||
rtest.Equals(t, uint(2), num)
|
|
||||||
num = mIdx.Count(restic.TreeBlob)
|
|
||||||
rtest.Equals(t, uint(2), num)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMasterMergeFinalIndexes(t *testing.T) {
|
func TestMasterMergeFinalIndexes(t *testing.T) {
|
||||||
|
@ -374,7 +374,7 @@ func benchmarkLoadIndex(b *testing.B, version uint) {
|
|||||||
id, err := repository.SaveIndex(context.TODO(), repo, idx)
|
id, err := repository.SaveIndex(context.TODO(), repo, idx)
|
||||||
rtest.OK(b, err)
|
rtest.OK(b, err)
|
||||||
|
|
||||||
b.Logf("index saved as %v (%v entries)", id.Str(), idx.Count(restic.DataBlob))
|
b.Logf("index saved as %v", id.Str())
|
||||||
fi, err := repo.Backend().Stat(context.TODO(), restic.Handle{Type: restic.IndexFile, Name: id.String()})
|
fi, err := repo.Backend().Stat(context.TODO(), restic.Handle{Type: restic.IndexFile, Name: id.String()})
|
||||||
rtest.OK(b, err)
|
rtest.OK(b, err)
|
||||||
b.Logf("filesize is %v", fi.Size)
|
b.Logf("filesize is %v", fi.Size)
|
||||||
|
@ -76,7 +76,6 @@ type PackBlobs struct {
|
|||||||
type MasterIndex interface {
|
type MasterIndex interface {
|
||||||
Has(BlobHandle) bool
|
Has(BlobHandle) bool
|
||||||
Lookup(BlobHandle) []PackedBlob
|
Lookup(BlobHandle) []PackedBlob
|
||||||
Count(BlobType) uint
|
|
||||||
|
|
||||||
// Each returns a channel that yields all blobs known to the index. When
|
// Each returns a channel that yields all blobs known to the index. When
|
||||||
// the context is cancelled, the background goroutine terminates. This
|
// the context is cancelled, the background goroutine terminates. This
|
||||||
|
Loading…
Reference in New Issue
Block a user