1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-03-30 00:00:14 +01:00

Fix name including package name and variable shadowing package.

This commit is contained in:
Martin Smith 2025-03-23 10:01:19 +00:00
parent 5e7333d28d
commit 6e45c51509
6 changed files with 24 additions and 24 deletions

View file

@ -64,11 +64,11 @@ func TestRebuildIndex(t *testing.T) {
}
func TestRebuildIndexAlwaysFull(t *testing.T) {
indexFull := index.IndexFull
indexFull := index.Full
defer func() {
index.IndexFull = indexFull
index.Full = indexFull
}()
index.IndexFull = func(*index.Index) bool { return true }
index.Full = func(*index.Index) bool { return true }
testRebuildIndex(t, nil)
}

View file

@ -93,8 +93,8 @@ const (
indexMaxAge = 10 * time.Minute
)
// IndexFull returns true iff the index is "full enough" to be saved as a preliminary index.
var IndexFull = func(idx *Index) bool {
// Full returns true iff the index is "full enough" to be saved as a preliminary index.
var Full = func(idx *Index) bool {
idx.m.RLock()
defer idx.m.RUnlock()
@ -119,7 +119,7 @@ var IndexFull = func(idx *Index) bool {
return false
}
var IndexOversized = func(idx *Index) bool {
var Oversized = func(idx *Index) bool {
idx.m.RLock()
defer idx.m.RUnlock()
@ -258,8 +258,8 @@ func (idx *Index) EachByPack(ctx context.Context, packBlacklist restic.IDSet) <-
for packID, packByType := range byPack {
var result EachByPackResult
result.PackID = packID
for typ, pack := range packByType {
for _, e := range pack {
for typ, p := range packByType {
for _, e := range p {
result.Blobs = append(result.Blobs, idx.toPackedBlob(e, restic.BlobType(typ)).Blob)
}
}
@ -511,10 +511,10 @@ func DecodeIndex(buf []byte, id restic.ID) (idx *Index, err error) {
}
idx = NewIndex()
for _, pack := range idxJSON.Packs {
packID := idx.addToPacks(pack.ID)
for _, p := range idxJSON.Packs {
packID := idx.addToPacks(p.ID)
for _, blob := range pack.Blobs {
for _, blob := range p.Blobs {
idx.store(packID, restic.Blob{
BlobHandle: restic.BlobHandle{
Type: blob.Type,

View file

@ -24,7 +24,7 @@ func TestIndexOversized(t *testing.T) {
})
}
rtest.Assert(t, !IndexOversized(idx), "index should not be considered oversized")
rtest.Assert(t, !Oversized(idx), "index should not be considered oversized")
// Add one more blob to exceed the limit
idx.store(packID, restic.Blob{
@ -36,5 +36,5 @@ func TestIndexOversized(t *testing.T) {
Offset: uint(indexMaxBlobs+pack.MaxHeaderEntries) * 100,
})
rtest.Assert(t, IndexOversized(idx), "index should be considered oversized")
rtest.Assert(t, Oversized(idx), "index should be considered oversized")
}

View file

@ -211,7 +211,7 @@ func (mi *MasterIndex) finalizeFullIndexes() []*Index {
continue
}
if IndexFull(idx) {
if Full(idx) {
debug.Log("index %p is full", idx)
idx.Finalize()
list = append(list, idx)
@ -419,7 +419,7 @@ func (mi *MasterIndex) Rewrite(ctx context.Context, repo restic.Unpacked[restic.
newIndex := NewIndex()
for task := range rewriteCh {
// always rewrite indexes that include a pack that must be removed or that are not full
if len(task.idx.Packs().Intersect(excludePacks)) == 0 && IndexFull(task.idx) && !IndexOversized(task.idx) {
if len(task.idx.Packs().Intersect(excludePacks)) == 0 && Full(task.idx) && !Oversized(task.idx) {
// make sure that each pack is only stored exactly once in the index
excludePacks.Merge(task.idx.Packs())
// index is already up to date
@ -435,7 +435,7 @@ func (mi *MasterIndex) Rewrite(ctx context.Context, repo restic.Unpacked[restic.
for pbs := range task.idx.EachByPack(wgCtx, excludePacks) {
newIndex.StorePack(pbs.PackID, pbs.Blobs)
if IndexFull(newIndex) {
if Full(newIndex) {
select {
case saveCh <- newIndex:
case <-wgCtx.Done():
@ -532,7 +532,7 @@ func (mi *MasterIndex) SaveFallback(ctx context.Context, repo restic.SaverRemove
for pbs := range idx.EachByPack(wgCtx, excludePacks) {
newIndex.StorePack(pbs.PackID, pbs.Blobs)
p.Add(1)
if IndexFull(newIndex) {
if Full(newIndex) {
select {
case ch <- newIndex:
case <-wgCtx.Done():

View file

@ -466,16 +466,16 @@ func TestRewriteOversizedIndex(t *testing.T) {
const fullIndexCount = 1000
// replace index size checks for testing
originalIndexFull := index.IndexFull
originalIndexOversized := index.IndexOversized
originalIndexFull := index.Full
originalIndexOversized := index.Oversized
defer func() {
index.IndexFull = originalIndexFull
index.IndexOversized = originalIndexOversized
index.Full = originalIndexFull
index.Oversized = originalIndexOversized
}()
index.IndexFull = func(idx *index.Index) bool {
index.Full = func(idx *index.Index) bool {
return idx.Len(restic.DataBlob) > fullIndexCount
}
index.IndexOversized = func(idx *index.Index) bool {
index.Oversized = func(idx *index.Index) bool {
return idx.Len(restic.DataBlob) > 2*fullIndexCount
}

View file

@ -333,7 +333,7 @@ func TestRepositoryIncrementalIndex(t *testing.T) {
func testRepositoryIncrementalIndex(t *testing.T, version uint) {
repo, _, _ := repository.TestRepositoryWithVersion(t, version)
index.IndexFull = func(*index.Index) bool { return true }
index.Full = func(*index.Index) bool { return true }
// add a few rounds of packs
for j := 0; j < 5; j++ {