@@ -790,6 +790,23 @@ func supportsOverlay(home string, homeMagic graphdriver.FsMagic, rootUID, rootGI
790
790
return supportsDType , fmt .Errorf ("'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded.: %w" , graphdriver .ErrNotSupported )
791
791
}
792
792
793
+ func cp (r io.Reader , dest string , filename string ) error {
794
+ if seeker , ok := r .(io.Seeker ); ok {
795
+ if _ , err := seeker .Seek (0 , io .SeekStart ); err != nil {
796
+ return err
797
+ }
798
+ }
799
+
800
+ f , err := os .Create (filepath .Join (dest , filename ))
801
+ if err != nil {
802
+ return err
803
+ }
804
+ defer f .Close ()
805
+
806
+ _ , err = io .Copy (f , r )
807
+ return err
808
+ }
809
+
793
810
func (d * Driver ) useNaiveDiff () bool {
794
811
if d .usingComposefs {
795
812
return true
@@ -2329,17 +2346,25 @@ func (d *Driver) ApplyDiff(id, parent string, options graphdriver.ApplyDiffOpts)
2329
2346
return 0 , err
2330
2347
}
2331
2348
2332
- logrus .Debugf ("Applying tar in %s" , applyDir )
2333
- // Overlay doesn't need the parent id to apply the diff
2334
- if err := untar (options .Diff , applyDir , & archive.TarOptions {
2335
- UIDMaps : idMappings .UIDs (),
2336
- GIDMaps : idMappings .GIDs (),
2337
- IgnoreChownErrors : d .options .ignoreChownErrors ,
2338
- ForceMask : d .options .forceMask ,
2339
- WhiteoutFormat : d .getWhiteoutFormat (),
2340
- InUserNS : unshare .IsRootless (),
2341
- }); err != nil {
2342
- return 0 , err
2349
+ if options .LayerFilename != nil {
2350
+ logrus .Debugf ("Applying file in %s" , applyDir )
2351
+ err := cp (options .Diff , applyDir , * options .LayerFilename )
2352
+ if err != nil {
2353
+ return 0 , err
2354
+ }
2355
+ } else {
2356
+ logrus .Debugf ("Applying tar in %s" , applyDir )
2357
+ // Overlay doesn't need the parent id to apply the diff
2358
+ if err := untar (options .Diff , applyDir , & archive.TarOptions {
2359
+ UIDMaps : idMappings .UIDs (),
2360
+ GIDMaps : idMappings .GIDs (),
2361
+ IgnoreChownErrors : d .options .ignoreChownErrors ,
2362
+ ForceMask : d .options .forceMask ,
2363
+ WhiteoutFormat : d .getWhiteoutFormat (),
2364
+ InUserNS : unshare .IsRootless (),
2365
+ }); err != nil {
2366
+ return 0 , err
2367
+ }
2343
2368
}
2344
2369
2345
2370
return directory .Size (applyDir )
0 commit comments