metadata: preserve createdat on update
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
1e8c80ae09
commit
6fa9a0b2df
@ -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")
|
||||
|
@ -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)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user