diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b8ea99cf..d2e6a243 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -159,13 +159,11 @@ dependencies { * in the top-level `libs` folder to reflect that. * You can copy these libraries from ~/.gradle/caches/modules-2/files-2.1 */ - // later versions than 2.1.1 require newer kotlin version implementation(fileTree("${rootProject.rootDir}/libs/koin-android").include("*.jar")) implementation(fileTree("${rootProject.rootDir}/libs/koin-android").include("*.aar")) implementation(fileTree("${rootProject.rootDir}/libs").include("kotlin-bip39-jvm-1.0.6.jar")) - // dav4jvm - later versions of okhttp need kotlin > 1.9.0 implementation(fileTree("${rootProject.rootDir}/libs/dav4jvm").include("*.jar")) /** 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 12893a3d..9fb4d318 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 @@ -14,22 +14,20 @@ import at.bitfire.dav4jvm.PropertyFactory import at.bitfire.dav4jvm.PropertyRegistry import at.bitfire.dav4jvm.Response import at.bitfire.dav4jvm.Response.HrefRelation.SELF -import at.bitfire.dav4jvm.XmlUtils.NS_WEBDAV import at.bitfire.dav4jvm.exception.HttpException -import at.bitfire.dav4jvm.property.DisplayName -import at.bitfire.dav4jvm.property.ResourceType +import at.bitfire.dav4jvm.property.webdav.DisplayName +import at.bitfire.dav4jvm.property.webdav.NS_WEBDAV +import at.bitfire.dav4jvm.property.webdav.ResourceType import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.async -import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import okhttp3.ConnectionSpec import okhttp3.HttpUrl import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import okhttp3.RequestBody -import okhttp3.internal.closeQuietly import okio.BufferedSink import org.xmlpull.v1.XmlPullParser import java.io.IOException @@ -113,28 +111,10 @@ internal abstract class WebDavStorage( protected fun getInputStream(location: HttpUrl): InputStream { val davCollection = DavCollection(okHttpClient, location) - val pipedInputStream = PipedExceptionInputStream() - val pipedOutputStream = PipedOutputStream(pipedInputStream) - - GlobalScope.launch(Dispatchers.IO) { - try { - davCollection.get(accept = "", headers = null) { response -> - val inputStream = response.body?.byteStream() - ?: throw IOException("No response body") - debugLog { "getInputStream($location) = $response" } - pipedOutputStream.use { outputStream -> - inputStream.copyTo(outputStream) - } - } - } catch (e: Exception) { - debugLog { "Exception while getting input stream: $e" } - // pass exception to stream, so it gets thrown when stream is closed - // if we'd just throw it here, it would be uncaught, on a different thread - pipedInputStream.throwable = e - pipedOutputStream.closeQuietly() - } - } - return pipedInputStream + val response = davCollection.get(accept = "", headers = null) + debugLog { "getInputStream($location) = $response" } + if (response.code / 100 != 2) throw IOException("HTTP error ${response.code}") + return response.body?.byteStream() ?: throw IOException() } /** @@ -233,22 +213,10 @@ internal abstract class WebDavStorage( } } - private class PipedExceptionInputStream : PipedInputStream() { - var throwable: Throwable? = null - - override fun close() { - super.close() - throwable?.let { e -> - if (e is IOException) throw e - else throw IOException(e) - } - } - } - } /** - * A fake version of [at.bitfire.dav4jvm.property.GetLastModified] which we register + * A fake version of [at.bitfire.dav4jvm.property.webdav.GetLastModified] which we register * so we don't need to depend on `org.apache.commons.lang3` which is used for date parsing. */ class GetLastModified : Property { diff --git a/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavStoragePlugin.kt b/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavStoragePlugin.kt index 952a42cd..dc7e7289 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavStoragePlugin.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavStoragePlugin.kt @@ -11,9 +11,9 @@ import at.bitfire.dav4jvm.DavCollection import at.bitfire.dav4jvm.Response.HrefRelation.SELF import at.bitfire.dav4jvm.exception.HttpException import at.bitfire.dav4jvm.exception.NotFoundException -import at.bitfire.dav4jvm.property.DisplayName -import at.bitfire.dav4jvm.property.QuotaAvailableBytes -import at.bitfire.dav4jvm.property.ResourceType +import at.bitfire.dav4jvm.property.webdav.DisplayName +import at.bitfire.dav4jvm.property.webdav.QuotaAvailableBytes +import at.bitfire.dav4jvm.property.webdav.ResourceType import com.stevesoltys.seedvault.plugins.EncryptedMetadata import com.stevesoltys.seedvault.plugins.StoragePlugin import com.stevesoltys.seedvault.plugins.chunkFolderRegex diff --git a/app/src/main/java/com/stevesoltys/seedvault/storage/WebDavStoragePlugin.kt b/app/src/main/java/com/stevesoltys/seedvault/storage/WebDavStoragePlugin.kt index f8592af6..28241dee 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/storage/WebDavStoragePlugin.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/storage/WebDavStoragePlugin.kt @@ -9,8 +9,8 @@ import android.util.Log import at.bitfire.dav4jvm.DavCollection import at.bitfire.dav4jvm.Response.HrefRelation.SELF import at.bitfire.dav4jvm.exception.NotFoundException -import at.bitfire.dav4jvm.property.DisplayName -import at.bitfire.dav4jvm.property.ResourceType +import at.bitfire.dav4jvm.property.webdav.DisplayName +import at.bitfire.dav4jvm.property.webdav.ResourceType import com.stevesoltys.seedvault.crypto.KeyManager import com.stevesoltys.seedvault.plugins.chunkFolderRegex import com.stevesoltys.seedvault.plugins.webdav.DIRECTORY_ROOT diff --git a/libs/dav4jvm/Android.bp b/libs/dav4jvm/Android.bp index 3fae26c6..66092662 100644 --- a/libs/dav4jvm/Android.bp +++ b/libs/dav4jvm/Android.bp @@ -5,13 +5,13 @@ java_import { name: "seedvault-lib-dav4jvm", - jars: ["dav4jvm-2.2.1.jar"], + jars: ["dav4jvm-b8be778.jar"], sdk_version: "current", } java_import { name: "seedvault-lib-okhttp", - jars: ["okhttp-4.11.0.jar"], + jars: ["okhttp-4.12.0.jar"], sdk_version: "current", } diff --git a/libs/dav4jvm/dav4jvm-2.2.1.jar b/libs/dav4jvm/dav4jvm-2.2.1.jar deleted file mode 100644 index 582827d4..00000000 Binary files a/libs/dav4jvm/dav4jvm-2.2.1.jar and /dev/null differ diff --git a/libs/dav4jvm/dav4jvm-b8be778.jar b/libs/dav4jvm/dav4jvm-b8be778.jar new file mode 100644 index 00000000..5d5d633b Binary files /dev/null and b/libs/dav4jvm/dav4jvm-b8be778.jar differ diff --git a/libs/dav4jvm/okhttp-4.11.0.jar b/libs/dav4jvm/okhttp-4.11.0.jar deleted file mode 100644 index 2df9400d..00000000 Binary files a/libs/dav4jvm/okhttp-4.11.0.jar and /dev/null differ diff --git a/libs/dav4jvm/okhttp-4.12.0.jar b/libs/dav4jvm/okhttp-4.12.0.jar new file mode 100644 index 00000000..faf3fa86 Binary files /dev/null and b/libs/dav4jvm/okhttp-4.12.0.jar differ