Skip to content

Commit

Permalink
core: few "Date" fields overridden with wrong values during Copy Cons…
Browse files Browse the repository at this point in the history
…tructor

For some reason during Copy Constructor of the "DiskImage" class,
the "CreationDate" &"LastModified" are overridden from the correct date
of the original "DiskImage" to the current date, and additionally
the "ImageStatus" ends up always in "ImageStatus.LOCKED" status.

This definitely seems wrong and doesn't make any sense.

This code was refactored lately in:
https://gerrit.ovirt.org/c/ovirt-engine/+/117500/17/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/DiskImage.java#77

But it looks like this strange implementation started at 2012:
https://gerrit.ovirt.org/c/ovirt-engine/+/3835/4/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImage.java#350

Signed-off-by: Pavel Bar <pbar@redhat.com>
  • Loading branch information
barpavel committed Apr 24, 2022
1 parent 529f3aa commit c78eb31
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ protected DiskImage(DiskImage diskImage) {
setImageStatus(diskImage.getImageStatus());
if (diskImage.getLastModified() != null) {
setLastModified(diskImage.getLastModified());
} else {
setLastModified(new Date());
}
storageIds = new ArrayList<>(diskImage.storageIds);
setVmSnapshotId(diskImage.getVmSnapshotId());
Expand All @@ -111,9 +113,6 @@ protected DiskImage(DiskImage diskImage) {
// TODO: is it ok to use shallow copy here?!
snapshots = new ArrayList<>(diskImage.snapshots);
actualDiskWithSnapthotsSize = diskImage.actualDiskWithSnapthotsSize;
setCreationDate(new Date());
setLastModified(new Date());
setImageStatus(ImageStatus.LOCKED);
setDiskProfileId(diskImage.getDiskProfileId());
getImage().setSequenceNumber(diskImage.getImage().getSequenceNumber());
}
Expand Down

0 comments on commit c78eb31

Please sign in to comment.