mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 11:22:12 +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)
|
||||
|
||||
session.use { activeSession ->
|
||||
activeSession.openWrite("package", 0, cacheFile.length()).use { packageStream ->
|
||||
cacheFile.inputStream().use { fileStream ->
|
||||
fileStream.copyTo(packageStream)
|
||||
if (cacheFile.exists()) {
|
||||
session.use { activeSession ->
|
||||
activeSession.openWrite("package", 0, cacheFile.length()).use { 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()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user