Skip to content

Commit b66edeb

Browse files
authored
Merge pull request #357 from senbox-org/SNAP-3488_lib-gdal_fix
SNAP-3488_lib-gdal_fix
2 parents 73d8795 + b918244 commit b66edeb

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

lib-gdal/src/main/java/org/esa/snap/dataio/gdal/GDALVersion.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ static String fetchProcessOutput(Process process) throws IOException {
161161
}
162162
}
163163

164+
/**
165+
* Checks whether the internal GDAL distribution is detected as installed version
166+
* @param installedVersionPath the path of the detected installed version
167+
* @return {@code true} if the internal GDAL distribution is detected as installed version
168+
*/
169+
private static boolean isInternalVersionDetectedAsInstalledVersion(String installedVersionPath){
170+
if (installedVersionPath.equals(INTERNAL_VERSION.getLocation())) {
171+
if (logger.isLoggable(Level.FINE)) {
172+
logger.log(Level.FINE, () -> "Skipping detected internal GDAL " + INTERNAL_VERSION.id + " from distribution.");
173+
}
174+
return true;
175+
}
176+
return false;
177+
}
178+
164179
/**
165180
* Retrieves the installed GDAl versions on host OS by invoking 'gdalinfo --version' on every 'gdalinfo' executable path command and parsing the output.
166181
*
@@ -177,6 +192,9 @@ private static Map<String, GDALVersion> retrieveInstalledVersions() {
177192
}
178193
final Map<String, GDALVersion> gdalVersions = new LinkedHashMap<>();
179194
for (final String installedVersionsPath : installedVersionsPaths) {
195+
if (isInternalVersionDetectedAsInstalledVersion(installedVersionsPath)) {
196+
continue;
197+
}
180198
try {
181199
final String result = fetchProcessOutput(Runtime.getRuntime().exec(new String[]{installedVersionsPath + File.separator + GDALINFIO_EXECUTABLE_NAME, GDALINFO_EXECUTABLE_ARGS}));
182200
final String versionId = result.replaceAll("[\\s\\S]*?(\\d*\\.\\d*\\.\\d*)[\\s\\S]*$", "$1");

0 commit comments

Comments
 (0)