listobjectversions: Add shortcut for Veeam blocks (#10893)

Add shortcut for `APN/1.0 Veeam/1.0 Backup/10.0`

It requests unique blocks with a specific prefix. We skip 
scanning the parent directory for more objects matching the prefix.
This commit is contained in:
Klaus Post
2020-11-13 16:58:20 -08:00
committed by GitHub
parent 17a5ff51ff
commit b5a3d79bce
4 changed files with 34 additions and 7 deletions

View File

@@ -87,6 +87,9 @@ type listPathOptions struct {
// This means the cache metadata will not be persisted on disk.
// A transient result will never be returned from the cache so knowing the list id is required.
Transient bool
// singleObject will assume that prefix refers to an exact single object.
singleObject bool
}
func init() {
@@ -542,7 +545,7 @@ func (er *erasureObjects) listPath(ctx context.Context, o listPathOptions) (entr
console.Printf("listPath with options: %#v\n", o)
}
// See if we have the listing stored.
if !o.Create {
if !o.Create && !o.singleObject {
entries, err := er.streamMetadataParts(ctx, o)
switch err {
case nil, io.EOF, context.Canceled, context.DeadlineExceeded:
@@ -662,6 +665,10 @@ func (er *erasureObjects) listPath(ctx context.Context, o listPathOptions) (entr
// Write results to disk.
bw := newMetacacheBlockWriter(cacheCh, func(b *metacacheBlock) error {
if o.singleObject {
// Don't save single object listings.
return nil
}
if debugPrint {
console.Println("listPath: saving block", b.n, "to", o.objectPath(b.n))
}