2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 03:18:55 +00:00

Merge pull request #2749 from aawsome/fix-fullindex

Change condition for full index
This commit is contained in:
MichaelEischer 2020-06-10 20:40:19 +02:00 committed by GitHub
commit 6856d1e422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,10 +59,8 @@ func (idx *Index) Final() bool {
} }
const ( const (
indexMinBlobs = 20 indexMaxBlobs = 50000
indexMaxBlobs = 2000 indexMaxAge = 10 * time.Minute
indexMinAge = 2 * time.Minute
indexMaxAge = 15 * time.Minute
) )
// IndexFull returns true iff the index is "full enough" to be saved as a preliminary index. // IndexFull returns true iff the index is "full enough" to be saved as a preliminary index.
@ -72,26 +70,21 @@ var IndexFull = func(idx *Index) bool {
debug.Log("checking whether index %p is full", idx) debug.Log("checking whether index %p is full", idx)
packs := len(idx.pack) blobs := len(idx.pack)
age := time.Now().Sub(idx.created) age := time.Now().Sub(idx.created)
if age > indexMaxAge { switch {
case age >= indexMaxAge:
debug.Log("index %p is old enough", idx, age) debug.Log("index %p is old enough", idx, age)
return true return true
} case blobs >= indexMaxBlobs:
debug.Log("index %p has %d blobs", idx, blobs)
if packs < indexMinBlobs || age < indexMinAge {
debug.Log("index %p only has %d packs or is too young (%v)", idx, packs, age)
return false
}
if packs > indexMaxBlobs {
debug.Log("index %p has %d packs", idx, packs)
return true return true
} }
debug.Log("index %p is not full", idx) debug.Log("index %p only has %d blobs and is too young (%v)", idx, blobs, age)
return false return false
} }
// Store remembers the id and pack in the index. An existing entry will be // Store remembers the id and pack in the index. An existing entry will be