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
parent
fabf6808ec
commit
fb83864eb9
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue