Fix error handling in CoroutineIntentService

This commit is contained in:
Koitharu
2023-01-04 14:39:36 +02:00
parent 571b85dfd8
commit f115031846
2 changed files with 9 additions and 3 deletions

View File

@@ -31,6 +31,9 @@ abstract class CoroutineIntentService : BaseService() {
processIntent(startId, intent)
}
}
} catch (e: Throwable) {
e.printStackTraceDebug()
onError(startId, e)
} finally {
stopSelf(startId)
}

View File

@@ -52,10 +52,13 @@ class ZipOutput(
return if (entryNames.add(entry.name)) {
val zipEntry = ZipEntry(entry.name)
output.putNextEntry(zipEntry)
other.getInputStream(entry).use { input ->
input.copyTo(output)
try {
other.getInputStream(entry).use { input ->
input.copyTo(output)
}
} finally {
output.closeEntry()
}
output.closeEntry()
true
} else {
false