Skip to content

Commit 70f8661

Browse files
committed
Fix a bug in updating template_store_ref entry.
1 parent e8c6963 commit 70f8661

3 files changed

Lines changed: 42 additions & 33 deletions

File tree

plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,20 @@ protected Void createAsyncCallback(AsyncCallbackDispatcher<CloudStackImageStoreD
175175
DataObject obj = context.data;
176176
DataStore store = obj.getDataStore();
177177

178-
TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
179-
updateBuilder.setDownloadPercent(answer.getDownloadPct());
180-
updateBuilder.setDownloadState(answer.getDownloadStatus());
181-
updateBuilder.setLastUpdated(new Date());
182-
updateBuilder.setErrorString(answer.getErrorString());
183-
updateBuilder.setJobId(answer.getJobId());
184-
updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
185-
updateBuilder.setInstallPath(answer.getInstallPath());
186-
updateBuilder.setSize(answer.getTemplateSize());
187-
updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
188-
_templateStoreDao.update(store.getId(), updateBuilder);
178+
TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(),obj.getId());
179+
if (tmpltStoreVO != null) {
180+
TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
181+
updateBuilder.setDownloadPercent(answer.getDownloadPct());
182+
updateBuilder.setDownloadState(answer.getDownloadStatus());
183+
updateBuilder.setLastUpdated(new Date());
184+
updateBuilder.setErrorString(answer.getErrorString());
185+
updateBuilder.setJobId(answer.getJobId());
186+
updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
187+
updateBuilder.setInstallPath(answer.getInstallPath());
188+
updateBuilder.setSize(answer.getTemplateSize());
189+
updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
190+
_templateStoreDao.update(tmpltStoreVO.getId(), updateBuilder);
191+
}
189192

190193
AsyncCompletionCallback<CreateCmdResult> caller = context.getParentCallback();
191194

plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,20 @@ protected Void createAsyncCallback(AsyncCallbackDispatcher<S3ImageStoreDriverImp
225225
DataObject obj = context.data;
226226
DataStore store = obj.getDataStore();
227227

228-
TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
229-
updateBuilder.setDownloadPercent(answer.getDownloadPct());
230-
updateBuilder.setDownloadState(answer.getDownloadStatus());
231-
updateBuilder.setLastUpdated(new Date());
232-
updateBuilder.setErrorString(answer.getErrorString());
233-
updateBuilder.setJobId(answer.getJobId());
234-
updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
235-
updateBuilder.setInstallPath(answer.getInstallPath());
236-
updateBuilder.setSize(answer.getTemplateSize());
237-
updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
238-
_templateStoreDao.update(store.getId(), updateBuilder);
228+
TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(),obj.getId());
229+
if (tmpltStoreVO != null) {
230+
TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
231+
updateBuilder.setDownloadPercent(answer.getDownloadPct());
232+
updateBuilder.setDownloadState(answer.getDownloadStatus());
233+
updateBuilder.setLastUpdated(new Date());
234+
updateBuilder.setErrorString(answer.getErrorString());
235+
updateBuilder.setJobId(answer.getJobId());
236+
updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
237+
updateBuilder.setInstallPath(answer.getInstallPath());
238+
updateBuilder.setSize(answer.getTemplateSize());
239+
updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
240+
_templateStoreDao.update(tmpltStoreVO.getId(), updateBuilder);
241+
}
239242

240243
AsyncCompletionCallback<CreateCmdResult> caller = context.getParentCallback();
241244

plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,20 @@ protected Void createAsyncCallback(AsyncCallbackDispatcher<SwiftImageStoreDriver
178178
DataObject obj = context.data;
179179
DataStore store = obj.getDataStore();
180180

181-
TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
182-
updateBuilder.setDownloadPercent(answer.getDownloadPct());
183-
updateBuilder.setDownloadState(answer.getDownloadStatus());
184-
updateBuilder.setLastUpdated(new Date());
185-
updateBuilder.setErrorString(answer.getErrorString());
186-
updateBuilder.setJobId(answer.getJobId());
187-
updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
188-
updateBuilder.setInstallPath(answer.getInstallPath());
189-
updateBuilder.setSize(answer.getTemplateSize());
190-
updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
191-
_templateStoreDao.update(store.getId(), updateBuilder);
181+
TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(),obj.getId());
182+
if (tmpltStoreVO != null) {
183+
TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
184+
updateBuilder.setDownloadPercent(answer.getDownloadPct());
185+
updateBuilder.setDownloadState(answer.getDownloadStatus());
186+
updateBuilder.setLastUpdated(new Date());
187+
updateBuilder.setErrorString(answer.getErrorString());
188+
updateBuilder.setJobId(answer.getJobId());
189+
updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
190+
updateBuilder.setInstallPath(answer.getInstallPath());
191+
updateBuilder.setSize(answer.getTemplateSize());
192+
updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
193+
_templateStoreDao.update(tmpltStoreVO.getId(), updateBuilder);
194+
}
192195

193196
AsyncCompletionCallback<CreateCmdResult> caller = context.getParentCallback();
194197

0 commit comments

Comments
 (0)