Improve logging relevant for WebDAV streams

This commit is contained in:
Torsten Grote 2024-06-18 14:04:58 -03:00
parent d5717496d7
commit 823eb4ffab
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF

View file

@ -20,7 +20,7 @@ import com.stevesoltys.seedvault.plugins.StoragePluginManager
import com.stevesoltys.seedvault.plugins.isOutOfSpace import com.stevesoltys.seedvault.plugins.isOutOfSpace
import com.stevesoltys.seedvault.settings.SettingsManager import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
import libcore.io.IoUtils.closeQuietly import java.io.Closeable
import java.io.EOFException import java.io.EOFException
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
@ -210,9 +210,9 @@ internal class FullBackup(
val state = this.state ?: throw AssertionError("Trying to clear empty state.") val state = this.state ?: throw AssertionError("Trying to clear empty state.")
return try { return try {
state.outputStream?.flush() state.outputStream?.flush()
closeQuietly(state.outputStream) closeLogging(state.outputStream)
closeQuietly(state.inputStream) closeLogging(state.inputStream)
closeQuietly(state.inputFileDescriptor) closeLogging(state.inputFileDescriptor)
TRANSPORT_OK TRANSPORT_OK
} catch (e: IOException) { } catch (e: IOException) {
Log.w(TAG, "Error when clearing state", e) Log.w(TAG, "Error when clearing state", e)
@ -222,4 +222,10 @@ internal class FullBackup(
} }
} }
private fun closeLogging(closable: Closeable?) = try {
closable?.close()
} catch (e: Exception) {
Log.w(TAG, "Error closing: ", e)
}
} }