Add trailing slash to WebDAV collection requests

This commit is contained in:
Torsten Grote 2024-06-13 09:32:00 -03:00
parent b223af6413
commit c522c460fd
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
2 changed files with 10 additions and 10 deletions

View file

@ -34,7 +34,7 @@ internal class WebDavStoragePlugin(
) : WebDavStorage(webDavConfig, root), StoragePlugin<WebDavConfig> {
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<EncryptedMetadata> {
val location = url.toHttpUrl()
val location = "$url/".toHttpUrl()
val davCollection = DavCollection(okHttpClient, location)
// get all restore set tokens in root folder

View file

@ -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<String> {
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<StoredSnapshot> {
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<StoredSnapshot> {
val location = "$url/$folder".toHttpUrl()
val location = "$url/$folder/".toHttpUrl()
val davCollection = DavCollection(okHttpClient, location)
debugLog { "getCurrentBackupSnapshots($location)" }