artifact extract: support reflink copy

When the fs supports reflinks use that over a normal copy, this speeds
things up a lot when big files are used.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2025-02-12 15:07:32 +01:00
parent 525b11e4c7
commit 3b5d7d1e64
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
1 changed files with 6 additions and 1 deletions

View File

@ -411,7 +411,12 @@ func copyImageBlobToFile(ctx context.Context, imgSrc types.ImageSource, digest d
}
defer dest.Close()
// TODO use reflink is possible
// By default the c/image oci layout API for GetBlob() should always return a os.File in our usage here.
// And since it is a file we can try to reflink it. In case it is not we should default to the normal copy.
if file, ok := src.(*os.File); ok {
return fileutils.ReflinkOrCopy(file, dest)
}
_, err = io.Copy(dest, src)
return err
}