Skip to content

Commit 9277ec6

Browse files
authored
Use streaming copy for config during copy and ensure to set target (#558)
2 parents 52e8687 + b94a544 commit 9277ec6

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/main/java/land/oras/CopyUtils.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,19 @@ void copy(
101101
Manifest manifest = source.getManifest(sourceRef);
102102
String tag = sourceRef.getTag();
103103

104-
// Write config as any blob
105104
Objects.requireNonNull(manifest.getDigest(), "Manifest digest is required for streaming copy");
106-
try (InputStream is = source.pullConfig(sourceRef, manifest.getConfig())) {
107-
LOG.debug("Copying config blob {}", manifest.getConfig().getDigest());
108-
target.pushBlob(targetRef.withDigest(manifest.getConfig().getDigest()), is);
109-
LOG.debug("Copied config blob {}", manifest.getConfig().getDigest());
110-
}
105+
106+
// Write config as any blob
107+
Config config = manifest.getConfig();
108+
Objects.requireNonNull(config.getDigest(), "Config digest is required for streaming copy");
109+
Objects.requireNonNull(config.getSize(), "Config size is required for streaming copy");
110+
target.pushBlob(
111+
targetRef
112+
.forTarget(effectiveTargetRegistry)
113+
.withDigest(manifest.getConfig().getDigest()),
114+
config.getSize(),
115+
() -> source.pullConfig(sourceRef.forTarget(resolveSourceRegistry), manifest.getConfig()),
116+
config.getAnnotations());
111117

112118
// Push the manifest
113119
LOG.debug("Copying manifest {}", manifestDigest);

0 commit comments

Comments
 (0)