Browse code

tarexport: check symlink error when saving layer

Signed-off-by: Stephen J Day <stephen.day@docker.com>

Stephen J Day authored on 2016/11/30 06:08:24
Showing 1 changed files
... ...
@@ -17,6 +17,7 @@ import (
17 17
 	"github.com/docker/docker/pkg/archive"
18 18
 	"github.com/docker/docker/pkg/system"
19 19
 	"github.com/docker/docker/reference"
20
+	"github.com/pkg/errors"
20 21
 )
21 22
 
22 23
 type imageDescriptor struct {
... ...
@@ -313,7 +314,9 @@ func (s *saveSession) saveLayer(id layer.ChainID, legacyImg image.V1Image, creat
313 313
 		if err != nil {
314 314
 			return distribution.Descriptor{}, err
315 315
 		}
316
-		os.Symlink(relPath, layerPath)
316
+		if err := os.Symlink(relPath, layerPath); err != nil {
317
+			return distribution.Descriptor{}, errors.Wrap(err, "error creating symlink while saving layer")
318
+		}
317 319
 	} else {
318 320
 		// Use system.CreateSequential rather than os.Create. This ensures sequential
319 321
 		// file access on Windows to avoid eating into MM standby list.