diff --git a/app/src/main/kotlin/com/syncflow/data/providers/webdav/WebDavProvider.kt b/app/src/main/kotlin/com/syncflow/data/providers/webdav/WebDavProvider.kt index 5d7012c..ff593ef 100644 --- a/app/src/main/kotlin/com/syncflow/data/providers/webdav/WebDavProvider.kt +++ b/app/src/main/kotlin/com/syncflow/data/providers/webdav/WebDavProvider.kt @@ -27,14 +27,7 @@ import java.util.concurrent.TimeUnit open class WebDavProvider(protected val account: CloudAccount) : CloudProvider { protected open val baseUrl: String - get() { - val raw = account.serverUrl?.trimEnd('/') ?: "" - // Silently upgrade http:// → https:// so that phone configs saved with - // http:// still work when the server only accepts HTTPS (e.g. behind Traefik - // with a global HTTP→HTTPS redirect). WebDAV methods (PROPFIND, MKCOL, MOVE) - // are not followed through redirects by OkHttp, so they would silently fail. - return if (raw.startsWith("http://")) "https://" + raw.removePrefix("http://") else raw - } + get() = account.serverUrl?.trimEnd('/') ?: "" protected val client: OkHttpClient by lazy { val creds = Json.parseToJsonElement(account.credentialJson).jsonObject @@ -157,7 +150,12 @@ open class WebDavProvider(protected val account: CloudAccount) : CloudProvider { withContext(Dispatchers.IO) { val req = Request.Builder().url(url(remotePath)).method("MKCOL", null).build() client.newCall(req).execute().use { resp -> - if (!resp.isSuccessful && resp.code != 405) throw Exception("MKCOL HTTP ${resp.code}") + // 405 = directory already exists (most servers) + // 423 = Locked — SFTPGo returns this when the dir exists and has a lock; + // treat as "already there", not a failure, so uploads inside it proceed. + if (!resp.isSuccessful && resp.code != 405 && resp.code != 423) { + throw Exception("MKCOL HTTP ${resp.code}") + } } } }