commit
d5717496d7
9 changed files with 15 additions and 49 deletions
|
@ -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"))
|
||||
|
||||
/**
|
||||
|
|
|
@ -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")
|
||||
val response = davCollection.get(accept = "", headers = null)
|
||||
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
|
||||
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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
BIN
libs/dav4jvm/dav4jvm-b8be778.jar
Normal file
BIN
libs/dav4jvm/dav4jvm-b8be778.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
libs/dav4jvm/okhttp-4.12.0.jar
Normal file
BIN
libs/dav4jvm/okhttp-4.12.0.jar
Normal file
Binary file not shown.
Loading…
Reference in a new issue