mirror of
https://github.com/restic/restic.git
synced 2025-08-23 19:47:36 +00:00
Merge pull request #2718 from aawsome/new-cleanup-command
Reimplementation of prune
This commit is contained in:
@@ -161,13 +161,16 @@ func (p *Packer) String() string {
|
||||
}
|
||||
|
||||
var (
|
||||
// size of the header-length field at the end of the file
|
||||
headerLengthSize = binary.Size(uint32(0))
|
||||
// we require at least one entry in the header, and one blob for a pack file
|
||||
minFileSize = entrySize + crypto.Extension + uint(headerLengthSize)
|
||||
)
|
||||
|
||||
const (
|
||||
// size of the header-length field at the end of the file; it is a uint32
|
||||
headerLengthSize = 4
|
||||
// constant overhead of the header independent of #entries
|
||||
HeaderSize = headerLengthSize + crypto.Extension
|
||||
|
||||
maxHeaderSize = 16 * 1024 * 1024
|
||||
// number of header enries to download as part of header-length request
|
||||
eagerEntries = 15
|
||||
@@ -315,3 +318,8 @@ func List(k *crypto.Key, rd io.ReaderAt, size int64) (entries []restic.Blob, err
|
||||
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
// PackedSizeOfBlob returns the size a blob actually uses when saved in a pack
|
||||
func PackedSizeOfBlob(blobLength uint) uint {
|
||||
return blobLength + entrySize
|
||||
}
|
||||
|
@@ -19,6 +19,10 @@ func (b Blob) String() string {
|
||||
b.Type, b.ID.Str(), b.Offset, b.Length)
|
||||
}
|
||||
|
||||
func (b Blob) Handle() BlobHandle {
|
||||
return BlobHandle{ID: b.ID, Type: b.Type}
|
||||
}
|
||||
|
||||
// PackedBlob is a blob stored within a file.
|
||||
type PackedBlob struct {
|
||||
Blob
|
||||
|
@@ -67,8 +67,12 @@ func LoadSnapshot(ctx context.Context, repo Repository, id ID) (*Snapshot, error
|
||||
}
|
||||
|
||||
// LoadAllSnapshots returns a list of all snapshots in the repo.
|
||||
func LoadAllSnapshots(ctx context.Context, repo Repository) (snapshots []*Snapshot, err error) {
|
||||
// If a snapshot ID is in excludeIDs, it will not be included in the result.
|
||||
func LoadAllSnapshots(ctx context.Context, repo Repository, excludeIDs IDSet) (snapshots []*Snapshot, err error) {
|
||||
err = repo.List(ctx, SnapshotFile, func(id ID, size int64) error {
|
||||
if excludeIDs.Has(id) {
|
||||
return nil
|
||||
}
|
||||
sn, err := LoadSnapshot(ctx, repo, id)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@@ -25,7 +25,7 @@ func TestCreateSnapshot(t *testing.T) {
|
||||
restic.TestCreateSnapshot(t, repo, testSnapshotTime.Add(time.Duration(i)*time.Second), testDepth, 0)
|
||||
}
|
||||
|
||||
snapshots, err := restic.LoadAllSnapshots(context.TODO(), repo)
|
||||
snapshots, err := restic.LoadAllSnapshots(context.TODO(), repo, restic.NewIDSet())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user