Skip to content

Commit db9de2e

Browse files
author
Mike Tutkowski
committed
CLOUDSTACK-6488 Fixed an issue where the "path" field was not being set properly in the DB when the volume had a snapshot taken of it
1 parent aabe6f2 commit db9de2e

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,21 +1169,28 @@ private String extractSnapshotBaseFileName(String input) {
11691169
if (input == null) {
11701170
return null;
11711171
}
1172+
11721173
String result = input;
1173-
if (result.endsWith(".vmdk")) { // get rid of vmdk file extension
1174-
result = result.substring(0, result.length() - (".vmdk").length());
1174+
1175+
final String fileType = ".vmdk";
1176+
1177+
if (result.endsWith(fileType)) {
1178+
// get rid of fileType
1179+
result = result.substring(0, result.length() - (fileType).length());
11751180
}
1176-
if (result.split("-").length == 1) {
1181+
1182+
String[] str = result.split("-");
1183+
int length = str.length;
1184+
1185+
if (length == 1 || length == 2) {
11771186
return result;
11781187
}
1179-
if (result.split("-").length > 2) {
1180-
return result.split("-")[0] + "-" + result.split("-")[1];
1181-
}
1182-
if (result.split("-").length == 2) {
1183-
return result.split("-")[0];
1184-
} else {
1185-
return result;
1188+
1189+
if (length > 2) {
1190+
return str[0] + "-" + str[1];
11861191
}
1192+
1193+
return result;
11871194
}
11881195

11891196
@Override

0 commit comments

Comments
 (0)