Added another try-catch to the native lib version check in case rights settings get weird (reported on MCF).

This commit is contained in:
Florian Nücke 2014-07-02 19:13:53 +02:00
parent da264e3aca
commit ce4316e91d

View File

@ -103,23 +103,29 @@ object LuaStateFactory {
// If the file, already exists, make sure it's the same we need, if it's
// not disable use of the natives.
if (file.exists()) {
val inCurrent = libraryUrl.openStream()
val inExisting = new FileInputStream(file)
var matching = true
var inCurrentByte = 0
var inExistingByte = 0
do {
inCurrentByte = inCurrent.read()
inExistingByte = inExisting.read()
if (inCurrentByte != inExistingByte) {
matching = false
inCurrentByte = -1
inExistingByte = -1
try {
val inCurrent = libraryUrl.openStream()
val inExisting = new FileInputStream(file)
var matching = true
var inCurrentByte = 0
var inExistingByte = 0
do {
inCurrentByte = inCurrent.read()
inExistingByte = inExisting.read()
if (inCurrentByte != inExistingByte) {
matching = false
inCurrentByte = -1
inExistingByte = -1
}
}
while (inCurrentByte != -1 && inExistingByte != -1)
inCurrent.close()
inExisting.close()
}
catch {
case _: Throwable =>
matching = false
}
while (inCurrentByte != -1 && inExistingByte != -1)
inCurrent.close()
inExisting.close()
if (!matching) {
// Try to delete an old instance of the library, in case we have an update
// and deleteOnExit fails (which it regularly does on Windows it seems).