mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Prevent DefaultInstaller from working on a non-existent cache file.
Ensures that the cache file exists before attempting an install using it. This fixes a crash that can occur if the file is not yet available, likely due to an I/O-related race condition.
This commit is contained in:
parent
3e8e23e111
commit
adf305ffc0
@ -51,16 +51,18 @@ class DefaultInstaller(context: Context) : BaseInstaller(context) {
|
|||||||
|
|
||||||
val session = sessionInstaller.openSession(id)
|
val session = sessionInstaller.openSession(id)
|
||||||
|
|
||||||
session.use { activeSession ->
|
if (cacheFile.exists()) {
|
||||||
activeSession.openWrite("package", 0, cacheFile.length()).use { packageStream ->
|
session.use { activeSession ->
|
||||||
cacheFile.inputStream().use { fileStream ->
|
activeSession.openWrite("package", 0, cacheFile.length()).use { packageStream ->
|
||||||
fileStream.copyTo(packageStream)
|
cacheFile.inputStream().use { fileStream ->
|
||||||
|
fileStream.copyTo(packageStream)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val pendingIntent = PendingIntent.getService(context, id, intent, flags)
|
||||||
|
|
||||||
|
session.commit(pendingIntent.intentSender)
|
||||||
}
|
}
|
||||||
|
|
||||||
val pendingIntent = PendingIntent.getService(context, id, intent, flags)
|
|
||||||
|
|
||||||
session.commit(pendingIntent.intentSender)
|
|
||||||
}
|
}
|
||||||
cacheFile.delete()
|
cacheFile.delete()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user