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:
parent
5e7333d28d
commit
6e45c51509
6 changed files with 24 additions and 24 deletions
|
@ -64,11 +64,11 @@ func TestRebuildIndex(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRebuildIndexAlwaysFull(t *testing.T) {
|
func TestRebuildIndexAlwaysFull(t *testing.T) {
|
||||||
indexFull := index.IndexFull
|
indexFull := index.Full
|
||||||
defer func() {
|
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)
|
testRebuildIndex(t, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,8 @@ const (
|
||||||
indexMaxAge = 10 * time.Minute
|
indexMaxAge = 10 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
// IndexFull returns true iff the index is "full enough" to be saved as a preliminary index.
|
// Full returns true iff the index is "full enough" to be saved as a preliminary index.
|
||||||
var IndexFull = func(idx *Index) bool {
|
var Full = func(idx *Index) bool {
|
||||||
idx.m.RLock()
|
idx.m.RLock()
|
||||||
defer idx.m.RUnlock()
|
defer idx.m.RUnlock()
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ var IndexFull = func(idx *Index) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var IndexOversized = func(idx *Index) bool {
|
var Oversized = func(idx *Index) bool {
|
||||||
idx.m.RLock()
|
idx.m.RLock()
|
||||||
defer idx.m.RUnlock()
|
defer idx.m.RUnlock()
|
||||||
|
|
||||||
|
@ -258,8 +258,8 @@ func (idx *Index) EachByPack(ctx context.Context, packBlacklist restic.IDSet) <-
|
||||||
for packID, packByType := range byPack {
|
for packID, packByType := range byPack {
|
||||||
var result EachByPackResult
|
var result EachByPackResult
|
||||||
result.PackID = packID
|
result.PackID = packID
|
||||||
for typ, pack := range packByType {
|
for typ, p := range packByType {
|
||||||
for _, e := range pack {
|
for _, e := range p {
|
||||||
result.Blobs = append(result.Blobs, idx.toPackedBlob(e, restic.BlobType(typ)).Blob)
|
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()
|
idx = NewIndex()
|
||||||
for _, pack := range idxJSON.Packs {
|
for _, p := range idxJSON.Packs {
|
||||||
packID := idx.addToPacks(pack.ID)
|
packID := idx.addToPacks(p.ID)
|
||||||
|
|
||||||
for _, blob := range pack.Blobs {
|
for _, blob := range p.Blobs {
|
||||||
idx.store(packID, restic.Blob{
|
idx.store(packID, restic.Blob{
|
||||||
BlobHandle: restic.BlobHandle{
|
BlobHandle: restic.BlobHandle{
|
||||||
Type: blob.Type,
|
Type: blob.Type,
|
||||||
|
|
|
@ -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
|
// Add one more blob to exceed the limit
|
||||||
idx.store(packID, restic.Blob{
|
idx.store(packID, restic.Blob{
|
||||||
|
@ -36,5 +36,5 @@ func TestIndexOversized(t *testing.T) {
|
||||||
Offset: uint(indexMaxBlobs+pack.MaxHeaderEntries) * 100,
|
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")
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ func (mi *MasterIndex) finalizeFullIndexes() []*Index {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if IndexFull(idx) {
|
if Full(idx) {
|
||||||
debug.Log("index %p is full", idx)
|
debug.Log("index %p is full", idx)
|
||||||
idx.Finalize()
|
idx.Finalize()
|
||||||
list = append(list, idx)
|
list = append(list, idx)
|
||||||
|
@ -419,7 +419,7 @@ func (mi *MasterIndex) Rewrite(ctx context.Context, repo restic.Unpacked[restic.
|
||||||
newIndex := NewIndex()
|
newIndex := NewIndex()
|
||||||
for task := range rewriteCh {
|
for task := range rewriteCh {
|
||||||
// always rewrite indexes that include a pack that must be removed or that are not full
|
// 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
|
// make sure that each pack is only stored exactly once in the index
|
||||||
excludePacks.Merge(task.idx.Packs())
|
excludePacks.Merge(task.idx.Packs())
|
||||||
// index is already up to date
|
// 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) {
|
for pbs := range task.idx.EachByPack(wgCtx, excludePacks) {
|
||||||
newIndex.StorePack(pbs.PackID, pbs.Blobs)
|
newIndex.StorePack(pbs.PackID, pbs.Blobs)
|
||||||
if IndexFull(newIndex) {
|
if Full(newIndex) {
|
||||||
select {
|
select {
|
||||||
case saveCh <- newIndex:
|
case saveCh <- newIndex:
|
||||||
case <-wgCtx.Done():
|
case <-wgCtx.Done():
|
||||||
|
@ -532,7 +532,7 @@ func (mi *MasterIndex) SaveFallback(ctx context.Context, repo restic.SaverRemove
|
||||||
for pbs := range idx.EachByPack(wgCtx, excludePacks) {
|
for pbs := range idx.EachByPack(wgCtx, excludePacks) {
|
||||||
newIndex.StorePack(pbs.PackID, pbs.Blobs)
|
newIndex.StorePack(pbs.PackID, pbs.Blobs)
|
||||||
p.Add(1)
|
p.Add(1)
|
||||||
if IndexFull(newIndex) {
|
if Full(newIndex) {
|
||||||
select {
|
select {
|
||||||
case ch <- newIndex:
|
case ch <- newIndex:
|
||||||
case <-wgCtx.Done():
|
case <-wgCtx.Done():
|
||||||
|
|
|
@ -466,16 +466,16 @@ func TestRewriteOversizedIndex(t *testing.T) {
|
||||||
const fullIndexCount = 1000
|
const fullIndexCount = 1000
|
||||||
|
|
||||||
// replace index size checks for testing
|
// replace index size checks for testing
|
||||||
originalIndexFull := index.IndexFull
|
originalIndexFull := index.Full
|
||||||
originalIndexOversized := index.IndexOversized
|
originalIndexOversized := index.Oversized
|
||||||
defer func() {
|
defer func() {
|
||||||
index.IndexFull = originalIndexFull
|
index.Full = originalIndexFull
|
||||||
index.IndexOversized = originalIndexOversized
|
index.Oversized = originalIndexOversized
|
||||||
}()
|
}()
|
||||||
index.IndexFull = func(idx *index.Index) bool {
|
index.Full = func(idx *index.Index) bool {
|
||||||
return idx.Len(restic.DataBlob) > fullIndexCount
|
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
|
return idx.Len(restic.DataBlob) > 2*fullIndexCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,7 +333,7 @@ func TestRepositoryIncrementalIndex(t *testing.T) {
|
||||||
func testRepositoryIncrementalIndex(t *testing.T, version uint) {
|
func testRepositoryIncrementalIndex(t *testing.T, version uint) {
|
||||||
repo, _, _ := repository.TestRepositoryWithVersion(t, version)
|
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
|
// add a few rounds of packs
|
||||||
for j := 0; j < 5; j++ {
|
for j := 0; j < 5; j++ {
|
||||||
|
|
Loading…
Add table
Reference in a new issue