@@ -28,17 +28,19 @@ import (
2828 "text/tabwriter"
2929 "time"
3030
31+ "github.com/containerd/log"
32+ digest "github.com/opencontainers/go-digest"
33+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
34+ "github.com/urfave/cli/v2"
35+
36+ containerd "github.com/containerd/containerd/v2/client"
3137 "github.com/containerd/containerd/v2/cmd/ctr/commands"
3238 "github.com/containerd/containerd/v2/core/content"
3339 "github.com/containerd/containerd/v2/core/diff"
3440 "github.com/containerd/containerd/v2/core/mount"
3541 "github.com/containerd/containerd/v2/core/snapshots"
3642 "github.com/containerd/containerd/v2/pkg/progress"
3743 "github.com/containerd/containerd/v2/pkg/rootfs"
38- "github.com/containerd/log"
39- digest "github.com/opencontainers/go-digest"
40- ocispec "github.com/opencontainers/image-spec/specs-go/v1"
41- "github.com/urfave/cli/v2"
4244)
4345
4446// Command is the cli command for managing snapshots
@@ -536,7 +538,12 @@ var unpackCommand = &cli.Command{
536538 Name : "unpack" ,
537539 Usage : "Unpack applies layers from a manifest to a snapshot" ,
538540 ArgsUsage : "[flags] <digest>" ,
539- Flags : commands .SnapshotterFlags ,
541+ Flags : append ([]cli.Flag {
542+ & cli.BoolFlag {
543+ Name : "sync-fs" ,
544+ Usage : "Synchronize the underlying filesystem containing files when unpack images, false by default" ,
545+ },
546+ }, commands .SnapshotterFlags ... ),
540547 Action : func (cliContext * cli.Context ) error {
541548 dgst , err := digest .Parse (cliContext .Args ().First ())
542549 if err != nil {
@@ -557,7 +564,7 @@ var unpackCommand = &cli.Command{
557564 for _ , image := range images {
558565 if image .Target ().Digest == dgst {
559566 fmt .Printf ("unpacking %s (%s)..." , dgst , image .Target ().MediaType )
560- if err := image .Unpack (ctx , cliContext .String ("snapshotter" )); err != nil {
567+ if err := image .Unpack (ctx , cliContext .String ("snapshotter" ), containerd . WithUnpackApplyOpts ( diff . WithSyncFs ( cliContext . Bool ( "sync-fs" ))) ); err != nil {
561568 fmt .Println ()
562569 return err
563570 }
0 commit comments