sureshanaparti commented on a change in pull request #4395:
URL: https://github.com/apache/cloudstack/pull/4395#discussion_r505352050
##########
File path:
engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/SecondaryStorageServiceImpl.java
##########
@@ -198,6 +204,39 @@ protected Void
migrateDataCallBack(AsyncCallbackDispatcher<SecondaryStorageServi
return null;
}
+ private void updateDataObject(DataObject srcData, DataObject destData) {
+ if (destData instanceof SnapshotInfo) {
+ SnapshotDataStoreVO snapshotStore =
snapshotStoreDao.findBySourceSnapshot(srcData.getId(), DataStoreRole.Image);
+ SnapshotDataStoreVO destSnapshotStore =
snapshotStoreDao.findBySnapshot(srcData.getId(), DataStoreRole.Image);
+ if (snapshotStore != null && destSnapshotStore != null) {
+
destSnapshotStore.setPhysicalSize(snapshotStore.getPhysicalSize());
+ destSnapshotStore.setCreated(snapshotStore.getCreated());
+ if (snapshotStore.getParentSnapshotId() !=
destSnapshotStore.getParentSnapshotId()) {
+
destSnapshotStore.setParentSnapshotId(snapshotStore.getParentSnapshotId());
+ }
+ snapshotStoreDao.update(destSnapshotStore.getId(),
destSnapshotStore);
+ }
+ }
+
+ if (destData instanceof VolumeInfo) {
+ VolumeDataStoreVO srcVolume =
volumeDataStoreDao.findByStoreVolume(srcData.getDataStore().getId(),
srcData.getId());
+ VolumeDataStoreVO destVolume =
volumeDataStoreDao.findByStoreVolume(destData.getDataStore().getId(),
destData.getId());
+ if (srcVolume != null && destVolume != null) {
+ destVolume.setPhysicalSize(srcVolume.getPhysicalSize());
+ destVolume.setCreated(srcVolume.getCreated());
+ volumeDataStoreDao.update(destVolume.getId(), destVolume);
+ }
+ }
+
+ if (destData instanceof TemplateInfo) {
Review comment:
@Pearl1594 better use if-else / switch-case. The control will come here
even when `destData` is of type SnapshotInfo. If this method is being called
for any other destData instance, better add a debug log for unsupported
instance.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]