metadata: preserve createdat on update

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2017-07-11 12:06:29 -07:00
parent 1e8c80ae09
commit 6fa9a0b2df
No known key found for this signature in database
GPG Key ID: 67B3DED84EDC823F
2 changed files with 4 additions and 1 deletions

View File

@ -140,6 +140,7 @@ func (s *containerStore) Update(ctx context.Context, container containers.Contai
if err := readContainer(&updated, cbkt); err != nil {
return updated, errors.Wrapf(err, "failed to read container from bucket")
}
createdat := updated.CreatedAt
updated.ID = container.ID
// apply the field mask. If you update this code, you better follow the
@ -178,6 +179,7 @@ func (s *containerStore) Update(ctx context.Context, container containers.Contai
updated = container
}
updated.CreatedAt = createdat
updated.UpdatedAt = time.Now().UTC()
if err := writeContainer(cbkt, &updated); err != nil {
return containers.Container{}, errors.Wrap(err, "failed to write container")

View File

@ -136,6 +136,7 @@ func (s *imageStore) Update(ctx context.Context, image images.Image, fieldpaths
if err := readImage(&updated, ibkt); err != nil {
return errors.Wrapf(err, "image %q", image.Name)
}
createdat := updated.CreatedAt
updated.Name = image.Name
if len(fieldpaths) > 0 {
@ -168,7 +169,7 @@ func (s *imageStore) Update(ctx context.Context, image images.Image, fieldpaths
updated = image
}
// TODO(stevvooe): Should only mark as updated if we have actual changes.
updated.CreatedAt = createdat
updated.UpdatedAt = time.Now().UTC()
return writeImage(ibkt, &updated)
})