Skip to content

Commit 79730ed

Browse files
CSTACKEX-18_2: fixing snapshot delete condition fix
1 parent 9c63c61 commit 79730ed

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDaoImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
6868
protected SearchBuilder<SnapshotDataStoreVO> searchFilteringStoreIdEqStateEqStoreRoleEqIdEqUpdateCountEqSnapshotIdEqVolumeIdEq;
6969
private SearchBuilder<SnapshotDataStoreVO> stateSearch;
7070
private SearchBuilder<SnapshotDataStoreVO> idStateNeqSearch;
71+
private SearchBuilder<SnapshotDataStoreVO> idStateNinSearch;
7172
protected SearchBuilder<SnapshotVO> snapshotVOSearch;
7273
private SearchBuilder<SnapshotDataStoreVO> snapshotCreatedSearch;
7374
private SearchBuilder<SnapshotDataStoreVO> dataStoreAndInstallPathSearch;
@@ -151,6 +152,11 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
151152
idStateNeqSearch.and(STATE, idStateNeqSearch.entity().getState(), SearchCriteria.Op.NEQ);
152153
idStateNeqSearch.done();
153154

155+
idStateNinSearch = createSearchBuilder();
156+
idStateNinSearch.and(SNAPSHOT_ID, idStateNinSearch.entity().getSnapshotId(), SearchCriteria.Op.EQ);
157+
idStateNinSearch.and(STATE, idStateNinSearch.entity().getState(), SearchCriteria.Op.NIN);
158+
idStateNinSearch.done();
159+
154160
snapshotVOSearch = snapshotDao.createSearchBuilder();
155161
snapshotVOSearch.and(VOLUME_ID, snapshotVOSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
156162
snapshotVOSearch.done();
@@ -488,7 +494,7 @@ public List<SnapshotDataStoreVO> findBySnapshotIdWithNonDestroyedState(long snap
488494

489495
@Override
490496
public List<SnapshotDataStoreVO> findBySnapshotIdAndNotInDestroyedHiddenState(long snapshotId) {
491-
SearchCriteria<SnapshotDataStoreVO> sc = idStateNeqSearch.create();
497+
SearchCriteria<SnapshotDataStoreVO> sc = idStateNinSearch.create();
492498
sc.setParameters(SNAPSHOT_ID, snapshotId);
493499
sc.setParameters(STATE, State.Destroyed.name(), State.Hidden.name());
494500
return listBy(sc);

0 commit comments

Comments
 (0)