[Android] Fix a performance issue when requesting the storage list from the remote access
Nicolas Pomepuy
git at videolan.org
Wed Feb 28 10:33:47 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Feb 27 09:22:49 2024 +0100| [0679e25f4e62cc41a2cfe1cda0fc91b3a8744ac6] | committer: Nicolas Pomepuy
Fix a performance issue when requesting the storage list from the remote access
> https://code.videolan.org/videolan/vlc-android/commit/0679e25f4e62cc41a2cfe1cda0fc91b3a8744ac6
---
.../videolan/vlc/webserver/RemoteAccessRouting.kt | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 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 560e74da82..df667e47b0 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
@@ -599,22 +599,12 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) {
}
// Launch asynchronous description calculations
getProviderDescriptions(appContext, scope, provider, dataset)
- observeLiveDataUntil(5000, dataset) {
- provider.loading.value == false
- }
-
- val list = dataset.getList().mapIndexed { index, mediaLibraryItem ->
- val path = when (mediaLibraryItem) {
- is MediaWrapper -> mediaLibraryItem.uri.toString()
- is Storage -> mediaLibraryItem.uri.toString()
- else -> throw IllegalStateException("Unrecognised media type")
-
- }
- val title = if ((provider.url == null || Uri.parse(provider.url).scheme.isSchemeFile()) && mediaLibraryItem is MediaWrapper)
- mediaLibraryItem.fileName else mediaLibraryItem.title
- val isFolder = if (mediaLibraryItem is MediaWrapper) mediaLibraryItem.type == MediaWrapper.TYPE_DIR else true
- RemoteAccessServer.PlayQueueItem(1000L + index, title, mediaLibraryItem.description ?: "", 0, mediaLibraryItem.artworkMrl
- ?: "", false, "", path, isFolder)
+ val list = try {
+ getProviderContent(appContext, provider, dataset, 1000L)
+ } catch (e: Exception) {
+ Log.e(this::class.java.simpleName, e.message, e)
+ call.respond(HttpStatusCode.InternalServerError)
+ return at get
}
val gson = Gson()
More information about the Android
mailing list