Only attempt to copy the bindir if it actually exists in our data.tar.gz

In commons-vfs 2.1-SNAPSHOT it appears that .getChild() is returning null
instead of raising a FileNotFoundException when the bindir isn't present. I
might be referring to outdated docs, but this resolves the issue and makes sure
there are not NPEs raised
This commit is contained in:
R. Tyler Croy 2015-08-10 05:41:49 -07:00
parent b4bfafcb45
commit 767161e069
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
1 changed files with 8 additions and 1 deletions

View File

@ -156,13 +156,20 @@ class GemInstaller {
protected void extractData(File installDir, FileObject dataTarGz, Gem gem) {
String dir = "${gem.name}-${gem.version.version}"
logger.info("Extracting into ${installDir} from ${gem.name}")
FileObject outputDir = fileSystemManager.resolveFile(new File(installDir, 'gems'), dir)
outputDir.copyFrom(dataTarGz, new AllFileSelector())
outputDir.close()
}
protected void extractExecutables(File installDir, FileObject dataTarGz, Gem gem) {
String binDir = gem.bindir ?: 'bin'
FileObject binObject = fileSystemManager.resolveFile(installDir, 'bin')
binObject.copyFrom(dataTarGz.getChild(gem.bindir), new AllFileSelector())
FileObject child = dataTarGz.getChild(binDir)
if (!child) {
return
}
binObject.copyFrom(child, new AllFileSelector())
binObject.close()
}
}