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 a2392ba2..b940e393 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 @@ -34,7 +34,7 @@ internal class WebDavStoragePlugin( ) : WebDavStorage(webDavConfig, root), StoragePlugin { override suspend fun test(): Boolean { - val location = baseUrl.toHttpUrl() + val location = (if (baseUrl.endsWith('/')) baseUrl else "$baseUrl/").toHttpUrl() val davCollection = DavCollection(okHttpClient, location) val webDavSupported = suspendCoroutine { cont -> @@ -50,7 +50,7 @@ internal class WebDavStoragePlugin( } override suspend fun getFreeSpace(): Long? { - val location = url.toHttpUrl() + val location = "$url/".toHttpUrl() val davCollection = DavCollection(okHttpClient, location) val availableBytes = suspendCoroutine { cont -> @@ -70,7 +70,7 @@ internal class WebDavStoragePlugin( @Throws(IOException::class) override suspend fun startNewRestoreSet(token: Long) { - val location = "$url/$token".toHttpUrl() + val location = "$url/$token/".toHttpUrl() val davCollection = DavCollection(okHttpClient, location) val response = davCollection.createFolder() @@ -81,7 +81,7 @@ internal class WebDavStoragePlugin( override suspend fun initializeDevice() { // TODO does it make sense to delete anything // when [startNewRestoreSet] is always called first? Maybe unify both calls? - val location = url.toHttpUrl() + val location = "$url/".toHttpUrl() val davCollection = DavCollection(okHttpClient, location) try { @@ -169,7 +169,7 @@ internal class WebDavStoragePlugin( } private suspend fun doGetAvailableBackups(): Sequence { - val location = url.toHttpUrl() + val location = "$url/".toHttpUrl() val davCollection = DavCollection(okHttpClient, location) // get all restore set tokens in root folder 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 a8b8d726..e3019868 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/storage/WebDavStoragePlugin.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/storage/WebDavStoragePlugin.kt @@ -49,7 +49,7 @@ internal class WebDavStoragePlugin( @Throws(IOException::class) override suspend fun init() { - val location = url.toHttpUrl() + val location = "$url/".toHttpUrl() val davCollection = DavCollection(okHttpClient, location) try { @@ -67,7 +67,7 @@ internal class WebDavStoragePlugin( @Throws(IOException::class) override suspend fun getAvailableChunkIds(): List { - val location = "$url/$folder".toHttpUrl() + val location = "$url/$folder/".toHttpUrl() val davCollection = DavCollection(okHttpClient, location) debugLog { "getAvailableChunkIds($location)" } @@ -117,7 +117,7 @@ internal class WebDavStoragePlugin( ) { val s = missingChunkFolders.size for ((i, chunkFolderName) in missingChunkFolders.withIndex()) { - val location = "$url/$folder/$chunkFolderName".toHttpUrl() + val location = "$url/$folder/$chunkFolderName/".toHttpUrl() val davCollection = DavCollection(okHttpClient, location) val response = davCollection.createFolder() debugLog { "Created missing folder $chunkFolderName (${i + 1}/$s) $response" } @@ -156,7 +156,7 @@ internal class WebDavStoragePlugin( @Throws(IOException::class) override suspend fun getBackupSnapshotsForRestore(): List { - val location = url.toHttpUrl() + val location = "$url/".toHttpUrl() val davCollection = DavCollection(okHttpClient, location) debugLog { "getBackupSnapshotsForRestore($location)" } @@ -220,7 +220,7 @@ internal class WebDavStoragePlugin( @Throws(IOException::class) override suspend fun getCurrentBackupSnapshots(): List { - val location = "$url/$folder".toHttpUrl() + val location = "$url/$folder/".toHttpUrl() val davCollection = DavCollection(okHttpClient, location) debugLog { "getCurrentBackupSnapshots($location)" }