Skip to content

Commit 101e2a0

Browse files
committed
fix logic to prevent take backup from failing
1 parent 348c9ee commit 101e2a0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,24 @@ private List<String> getVolumePaths(List<VolumeVO> volumes, List<Backup.VolumeIn
259259
} else {
260260
volumePathPrefix = String.format("/mnt/%s", storagePool.getUuid());
261261
}
262-
backedVolumes.stream().filter(backedVolume -> backedVolume.getUuid().equals(volume.getUuid())).findFirst()
263-
.ifPresent(backedVolume -> {
262+
boolean hasBackedVolumes = backedVolumes != null && !backedVolumes.isEmpty();
263+
if (hasBackedVolumes) {
264+
Optional<Backup.VolumeInfo> opt = backedVolumes.stream()
265+
.filter(bv -> bv.getUuid().equals(volume.getUuid())).findFirst();
266+
if (opt.isPresent()) {
267+
Backup.VolumeInfo backedVolume = opt.get();
264268
if (backedVolume.getPath() != null && !backedVolume.getPath().isEmpty()) {
265269
volumePaths.add(String.format("%s/%s", volumePathPrefix, backedVolume.getPath()));
266270
} else {
267271
volumePaths.add(String.format("%s/%s", volumePathPrefix, volume.getPath()));
268272
}
269-
});
273+
continue;
274+
}
275+
}
276+
277+
volumePaths.add(String.format("%s/%s", volumePathPrefix, volume.getPath()));
270278
}
279+
271280
return volumePaths;
272281
}
273282

0 commit comments

Comments
 (0)