diff --git a/internal/backend/mem/mem_backend.go b/internal/backend/mem/mem_backend.go index afd86cc73..0bb49e0b4 100644 --- a/internal/backend/mem/mem_backend.go +++ b/internal/backend/mem/mem_backend.go @@ -73,7 +73,7 @@ func (be *MemoryBackend) Save(ctx context.Context, h restic.Handle, rd restic.Re be.m.Lock() defer be.m.Unlock() - h.ContainedBlobType = restic.InvalidBlob + h.IsMetadata = false if h.Type == restic.ConfigFile { h.Name = "" } @@ -120,7 +120,7 @@ func (be *MemoryBackend) openReader(ctx context.Context, h restic.Handle, length be.m.Lock() defer be.m.Unlock() - h.ContainedBlobType = restic.InvalidBlob + h.IsMetadata = false if h.Type == restic.ConfigFile { h.Name = "" } @@ -147,7 +147,7 @@ func (be *MemoryBackend) Stat(ctx context.Context, h restic.Handle) (restic.File be.m.Lock() defer be.m.Unlock() - h.ContainedBlobType = restic.InvalidBlob + h.IsMetadata = false if h.Type == restic.ConfigFile { h.Name = "" } @@ -165,7 +165,7 @@ func (be *MemoryBackend) Remove(ctx context.Context, h restic.Handle) error { be.m.Lock() defer be.m.Unlock() - h.ContainedBlobType = restic.InvalidBlob + h.IsMetadata = false if _, ok := be.data[h]; !ok { return errNotFound } diff --git a/internal/cache/backend.go b/internal/cache/backend.go index 311b099ee..e76bcaa1b 100644 --- a/internal/cache/backend.go +++ b/internal/cache/backend.go @@ -48,7 +48,7 @@ func autoCacheTypes(h restic.Handle) bool { case restic.IndexFile, restic.SnapshotFile: return true case restic.PackFile: - return h.ContainedBlobType == restic.TreeBlob + return h.IsMetadata } return false } diff --git a/internal/repository/packer_manager.go b/internal/repository/packer_manager.go index 2e2368aad..dbd2e8427 100644 --- a/internal/repository/packer_manager.go +++ b/internal/repository/packer_manager.go @@ -163,7 +163,7 @@ func (r *Repository) savePacker(ctx context.Context, t restic.BlobType, p *Packe } id := restic.IDFromHash(hr.Sum(nil)) - h := restic.Handle{Type: restic.PackFile, Name: id.String(), ContainedBlobType: t} + h := restic.Handle{Type: restic.PackFile, Name: id.String(), IsMetadata: t.IsMetadata()} var beHash []byte if beHr != nil { beHash = beHr.Sum(nil) diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 8ec3c598e..0c270c6e0 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -284,7 +284,7 @@ func (r *Repository) LoadBlob(ctx context.Context, t restic.BlobType, id restic. } // load blob from pack - h := restic.Handle{Type: restic.PackFile, Name: blob.PackID.String(), ContainedBlobType: t} + h := restic.Handle{Type: restic.PackFile, Name: blob.PackID.String(), IsMetadata: t.IsMetadata()} switch { case cap(buf) < int(blob.Length): @@ -922,7 +922,7 @@ func StreamPack(ctx context.Context, beLoad BackendLoadFn, key *crypto.Key, pack } func streamPackPart(ctx context.Context, beLoad BackendLoadFn, key *crypto.Key, packID restic.ID, blobs []restic.Blob, handleBlobFn func(blob restic.BlobHandle, buf []byte, err error) error) error { - h := restic.Handle{Type: restic.PackFile, Name: packID.String(), ContainedBlobType: restic.DataBlob} + h := restic.Handle{Type: restic.PackFile, Name: packID.String(), IsMetadata: false} dataStart := blobs[0].Offset dataEnd := blobs[len(blobs)-1].Offset + blobs[len(blobs)-1].Length diff --git a/internal/restic/blob.go b/internal/restic/blob.go index 260f40fde..3a6872af3 100644 --- a/internal/restic/blob.go +++ b/internal/restic/blob.go @@ -75,6 +75,15 @@ func (t BlobType) String() string { return fmt.Sprintf("", t) } +func (t BlobType) IsMetadata() bool { + switch t { + case TreeBlob: + return true + default: + return false + } +} + // MarshalJSON encodes the BlobType into JSON. func (t BlobType) MarshalJSON() ([]byte, error) { switch t { diff --git a/internal/restic/file.go b/internal/restic/file.go index 0e9f046ae..15ee22ccd 100644 --- a/internal/restic/file.go +++ b/internal/restic/file.go @@ -41,9 +41,9 @@ func (t FileType) String() string { // Handle is used to store and access data in a backend. type Handle struct { - Type FileType - ContainedBlobType BlobType - Name string + Type FileType + IsMetadata bool + Name string } func (h Handle) String() string {