8267056: tools/jpackage/share/RuntimePackageTest.java fails with NoSuchFileException

Reviewed-by: asemenyuk, herrick
This commit is contained in:
Alexander Matveev 2021-05-21 00:44:39 +00:00
parent e094f3f856
commit 9eaa4afc99
2 changed files with 15 additions and 10 deletions

View File

@ -390,16 +390,20 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
Path rootDir = appLocation.getParent() == null ?
Path.of(".") : appLocation.getParent();
Path[] list = Files.list(rootDir).toArray(Path[]::new);
if (list != null) { // Should not happend
// We should only have app image and/or .DS_Store
if (list.length == 1) {
return rootDir.toString();
} else if (list.length == 2) {
// Check case with app image and .DS_Store
if (list[0].toString().toLowerCase().endsWith(".ds_store") ||
list[1].toString().toLowerCase().endsWith(".ds_store")) {
return rootDir.toString(); // Only app image and .DS_Store
// Not needed for runtime installer and it might break runtime installer
// if parent does not have any other files
if (!StandardBundlerParam.isRuntimeInstaller(params)) {
try (var fileList = Files.list(rootDir)) {
Path[] list = fileList.toArray(Path[]::new);
// We should only have app image and/or .DS_Store
if (list.length == 1) {
return rootDir.toString();
} else if (list.length == 2) {
// Check case with app image and .DS_Store
if (list[0].toString().toLowerCase().endsWith(".ds_store") ||
list[1].toString().toLowerCase().endsWith(".ds_store")) {
return rootDir.toString(); // Only app image and .DS_Store
}
}
}
}

View File

@ -151,6 +151,7 @@ public class RuntimePackageTest {
final Path prefsDir = Path.of(".systemPrefs");
return files.map(root::relativize)
.filter(x -> !x.startsWith(prefsDir))
.filter(x -> !x.endsWith(".DS_Store"))
.collect(Collectors.toSet());
}
}