add previews in binary content

This commit is contained in:
2022-03-18 19:04:57 +06:00
parent 787f8d7526
commit 72578f6b58
13 changed files with 254 additions and 49 deletions

View File

@@ -115,4 +115,25 @@ class ServerContentStorageAggregator(
return currentResults.createPaginationResult(pagination, count())
}
override suspend fun getContentPreview(id: ContentId): RegisteredContent? {
val result = CompletableDeferred<RegisteredContent>()
storages.map {
scope.launch {
val content = it.getContentPreview(id)
if (content != null) {
result.complete(content)
}
}.also { job ->
result.invokeOnCompletion { job.cancel() }
}
}.joinAll()
return if (result.isCompleted) {
result.getCompleted()
} else {
return null
}
}
}