|
18 | 18 | */ |
19 | 19 | package org.apache.cloudstack.utils.imagestore; |
20 | 20 |
|
21 | | -import com.cloud.utils.UriUtils; |
22 | | -import com.cloud.utils.script.Script; |
23 | 21 | import org.apache.commons.lang.StringUtils; |
24 | 22 | import org.apache.log4j.Logger; |
25 | 23 |
|
| 24 | +import com.cloud.utils.UriUtils; |
| 25 | +import com.cloud.utils.script.Script; |
| 26 | + |
26 | 27 | public class ImageStoreUtil { |
27 | 28 | public static final Logger s_logger = Logger.getLogger(ImageStoreUtil.class.getName()); |
28 | 29 |
|
@@ -58,7 +59,7 @@ public static String checkTemplateFormat(String path, String uripath) { |
58 | 59 | return ""; |
59 | 60 | } |
60 | 61 | // raw |
61 | | - if ((output.contains("x86 boot") || output.contains("data")) && (isCorrectExtension(uripath, "raw"))) { |
| 62 | + if ((output.contains("x86 boot") || output.contains("data")) && (isCorrectExtension(uripath, "raw") || isCorrectExtension(uripath, "img"))) { |
62 | 63 | s_logger.debug("File at path " + path + " looks like a raw image :" + output); |
63 | 64 | return ""; |
64 | 65 | } |
@@ -93,10 +94,11 @@ public static String checkTemplateFormat(String path, String uripath) { |
93 | 94 |
|
94 | 95 | public static boolean isCorrectExtension(String path, String format) { |
95 | 96 | final String lowerCasePath = path.toLowerCase(); |
96 | | - return UriUtils.getSupportedExtensions(format) |
97 | | - .stream() |
98 | | - .filter(ext -> !ext.equals(".metalink")) |
99 | | - .anyMatch(lowerCasePath::endsWith); |
| 97 | + return lowerCasePath.endsWith(format) || |
| 98 | + UriUtils.getSupportedExtensions(format) |
| 99 | + .stream() |
| 100 | + .filter(ext -> !ext.equals(".metalink")) |
| 101 | + .anyMatch(lowerCasePath::endsWith); |
100 | 102 | } |
101 | 103 |
|
102 | 104 | public static boolean isCompressedExtension(String path) { |
|
0 commit comments