Fix transformation file path with locale specific files (#1661)

The path is incorrect because a bug was introduced in #1650.
This results in the MapTransformationServiceTest failing so it was disabled in openhab/openhab-addons#8519.

Signed-off-by: Wouter Born <github@maindrain.net>
pull/1665/head
Wouter Born 2020-09-22 08:20:11 +02:00 committed by GitHub
parent fabf6808ec
commit fb83864eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -266,17 +266,19 @@ public abstract class AbstractFileTransformationService<T> implements Transforma
watchSubDirectory(file.getParent(), watchService); watchSubDirectory(file.getParent(), watchService);
} }
String sourcePath = getSourcePath();
String extension = getFileExtension(filename); String extension = getFileExtension(filename);
// the filename may already contain locale information // the filename may already contain locale information
if (!filename.matches(".*_[a-z]{2}." + extension + "$")) { if (!filename.matches(".*_[a-z]{2}." + extension + "$")) {
String alternateName = filename + "_" + getLocale().getLanguage() + "." + extension; String alternatePath = sourcePath + filename.substring(0, filename.length() - extension.length() - 1) + "_"
String alternatePath = getSourcePath() + alternateName; + getLocale().getLanguage() + "." + extension;
if (new File(alternatePath).exists()) { if (new File(alternatePath).exists()) {
return alternatePath; return alternatePath;
} }
} }
return getSourcePath() + filename; return sourcePath + filename;
} }
/** /**