Add updatedFrom param in marketplace plugin download requests

Fix npe

Add updatedFrom param in marketplace plugin download requests


Merge-request: IJ-MR-122517
Merged-by: Sergey Kesarev <sergey.kesarev@jetbrains.com>

GitOrigin-RevId: d858958b5afb63e04ba978269652dba9383cb638
This commit is contained in:
Sergey.Kesarev
2023-12-19 17:14:48 +00:00
committed by intellij-monorepo-bot
parent 87424cacb2
commit c14b9cdd8b
3 changed files with 12 additions and 4 deletions
@@ -842,7 +842,7 @@ object PluginManagerCore {
@Internal
@JvmStatic
fun findPlugin(id: PluginId): IdeaPluginDescriptorImpl? {
val pluginSet = getPluginSet()
val pluginSet = nullablePluginSet ?: return null
return pluginSet.findEnabledPlugin(id) ?: pluginSet.findInstalledPlugin(id)
}
@@ -85,11 +85,18 @@ internal object MarketplaceUrls {
}
@JvmStatic
fun getPluginDownloadUrl(descriptor: IdeaPluginDescriptor, uuid: String, buildNumber: BuildNumber?): String {
fun getPluginDownloadUrl(
descriptor: IdeaPluginDescriptor,
uuid: String,
buildNumber: BuildNumber?,
currentVersion: IdeaPluginDescriptor?
): String {
val updatedFrom = currentVersion?.version ?: ""
val parameters = hashMapOf(
"id" to descriptor.pluginId.idString,
"build" to ApplicationInfoImpl.orFromPluginCompatibleBuild(buildNumber),
"uuid" to uuid
"uuid" to uuid,
"updatedFrom" to updatedFrom
)
(descriptor as? PluginNode)?.channel?.let {
parameters["channel"] = it
@@ -379,9 +379,10 @@ public final class PluginDownloader {
public static @NotNull PluginDownloader createDownloader(@NotNull IdeaPluginDescriptor descriptor,
@Nullable String host,
@Nullable BuildNumber buildNumber) throws IOException {
IdeaPluginDescriptor currentVersion = PluginManagerCore.getPlugin(descriptor.getPluginId());
String url = descriptor instanceof PluginNode && host != null ?
toAbsoluteUrl(((PluginNode)descriptor).getDownloadUrl(), host) :
MarketplaceUrls.getPluginDownloadUrl(descriptor, getMarketplaceDownloadsUUID(), buildNumber);
MarketplaceUrls.getPluginDownloadUrl(descriptor, getMarketplaceDownloadsUUID(), buildNumber, currentVersion);
return new PluginDownloader(descriptor,
url,