forked from TrueCloudLab/restic
Add Index.LookupSize
This commit is contained in:
parent
c9d8ab9be5
commit
ca6b7ec533
2 changed files with 13 additions and 3 deletions
|
@ -2,7 +2,6 @@ package fuse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/restic/restic"
|
"github.com/restic/restic"
|
||||||
"github.com/restic/restic/crypto"
|
|
||||||
"github.com/restic/restic/pack"
|
"github.com/restic/restic/pack"
|
||||||
"github.com/restic/restic/repository"
|
"github.com/restic/restic/repository"
|
||||||
|
|
||||||
|
@ -25,11 +24,11 @@ type file struct {
|
||||||
func newFile(repo *repository.Repository, node *restic.Node) (*file, error) {
|
func newFile(repo *repository.Repository, node *restic.Node) (*file, error) {
|
||||||
sizes := make([]uint32, len(node.Content))
|
sizes := make([]uint32, len(node.Content))
|
||||||
for i, blobId := range node.Content {
|
for i, blobId := range node.Content {
|
||||||
_, _, _, length, err := repo.Index().Lookup(blobId)
|
length, err := repo.Index().LookupSize(blobId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
sizes[i] = uint32(length) - crypto.Extension
|
sizes[i] = uint32(length)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &file{
|
return &file{
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/restic/restic/backend"
|
"github.com/restic/restic/backend"
|
||||||
|
"github.com/restic/restic/crypto"
|
||||||
"github.com/restic/restic/debug"
|
"github.com/restic/restic/debug"
|
||||||
"github.com/restic/restic/pack"
|
"github.com/restic/restic/pack"
|
||||||
)
|
)
|
||||||
|
@ -91,6 +92,16 @@ func (idx *Index) Has(id backend.ID) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LookupSize returns the length of the cleartext content behind the
|
||||||
|
// given id
|
||||||
|
func (idx *Index) LookupSize(id backend.ID) (cleartextLength uint, err error) {
|
||||||
|
_, _, _, encryptedLength, err := idx.Lookup(id)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return encryptedLength - crypto.Extension, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Merge loads all items from other into idx.
|
// Merge loads all items from other into idx.
|
||||||
func (idx *Index) Merge(other *Index) {
|
func (idx *Index) Merge(other *Index) {
|
||||||
debug.Log("Index.Merge", "Merge index with %p", other)
|
debug.Log("Index.Merge", "Merge index with %p", other)
|
||||||
|
|
Loading…
Reference in a new issue