[Android] Remote access: return an error when trying to create an existing playlist
Nicolas Pomepuy
git at videolan.org
Tue Jun 25 12:16:39 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jun 25 07:41:04 2024 +0200| [9ae9af47ebbff9086b25acbce734a6016f10a2ee] | committer: Duncan McNamara
Remote access: return an error when trying to create an existing playlist
> https://code.videolan.org/videolan/vlc-android/commit/9ae9af47ebbff9086b25acbce734a6016f10a2ee
---
.../java/org/videolan/vlc/webserver/RemoteAccessRouting.kt | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt
index 8dd167f926..47d1cb22ae 100644
--- a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt
+++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt
@@ -574,13 +574,18 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) {
}
val name = formParameters?.get("name") ?: call.respond(HttpStatusCode.NoContent)
- appContext.getFromMl {
+ val created = appContext.getFromMl {
if (getPlaylistByName(name as String) == null) {
createPlaylist(name, true, false)
+ true
+ } else {
+ false
}
}
-
- call.respondText("")
+ if (!created)
+ call.respond(HttpStatusCode.Conflict, appContext.getString(R.string.playlist_existing, name))
+ else
+ call.respondText("")
}
// Add a media to playlists
post("/playlist-add") {
More information about the Android
mailing list