@@ -37,9 +37,9 @@ import (
37
37
// defaultConcurrency is the default value of CopyGraphOptions.Concurrency.
38
38
const defaultConcurrency int = 3 // This value is consistent with dockerd and containerd.
39
39
40
- // ErrSkipDesc signals to stop copying a descriptor. When returned from PreCopy the blob must exist in the target.
40
+ // SkipNode signals to stop copying a node. When returned from PreCopy the blob must exist in the target.
41
41
// This can be used to signal that a blob has been made available in the target repository by "Mount()" or some other technique.
42
- var ErrSkipDesc = errors .New ("skip descriptor " )
42
+ var SkipNode = errors .New ("skip node " )
43
43
44
44
// DefaultCopyOptions provides the default CopyOptions.
45
45
var DefaultCopyOptions CopyOptions = CopyOptions {
@@ -96,9 +96,11 @@ type CopyGraphOptions struct {
96
96
// cached in the memory.
97
97
// If less than or equal to 0, a default (currently 4 MiB) is used.
98
98
MaxMetadataBytes int64
99
- // PreCopy handles the current descriptor before copying it.
99
+ // PreCopy handles the current descriptor before it is copied. PreCopy can
100
+ // return a SkipNode to signal that desc should be skipped when it already
101
+ // exists in the target.
100
102
PreCopy func (ctx context.Context , desc ocispec.Descriptor ) error
101
- // PostCopy handles the current descriptor after copying it .
103
+ // PostCopy handles the current descriptor after it is copied .
102
104
PostCopy func (ctx context.Context , desc ocispec.Descriptor ) error
103
105
// OnCopySkipped will be called when the sub-DAG rooted by the current node
104
106
// is skipped.
@@ -282,7 +284,7 @@ func doCopyNode(ctx context.Context, src content.ReadOnlyStorage, dst content.St
282
284
func copyNode (ctx context.Context , src content.ReadOnlyStorage , dst content.Storage , desc ocispec.Descriptor , opts CopyGraphOptions ) error {
283
285
if opts .PreCopy != nil {
284
286
if err := opts .PreCopy (ctx , desc ); err != nil {
285
- if err == ErrSkipDesc {
287
+ if err == SkipNode {
286
288
return nil
287
289
}
288
290
return err
@@ -374,7 +376,7 @@ func prepareCopy(ctx context.Context, dst Target, dstRef string, proxy *cas.Prox
374
376
}
375
377
}
376
378
// skip the regular copy workflow
377
- return ErrSkipDesc
379
+ return SkipNode
378
380
}
379
381
} else {
380
382
postCopy := opts .PostCopy
0 commit comments