diff --git a/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavStorage.kt b/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavStorage.kt index 9fb4d318..faec3f84 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavStorage.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavStorage.kt @@ -197,6 +197,32 @@ internal abstract class WebDavStorage( private var onClose: (() -> Unit)? = null + override fun write(b: Int) { + try { + super.write(b) + } catch (e: Exception) { + try { + onClose?.invoke() + } catch (closeException: Exception) { + e.addSuppressed(closeException) + } + throw e + } + } + + override fun write(b: ByteArray?, off: Int, len: Int) { + try { + super.write(b, off, len) + } catch (e: Exception) { + try { + onClose?.invoke() + } catch (closeException: Exception) { + e.addSuppressed(closeException) + } + throw e + } + } + @Throws(IOException::class) override fun close() { super.close()