mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-134737 (full fix)
- file name is never set and need not to be cached - plugin ID is used in unlikely case of missing plugin name
This commit is contained in:
+11
-28
@@ -56,28 +56,25 @@ public class PluginDownloader {
|
||||
|
||||
private final String myPluginId;
|
||||
private final String myPluginUrl;
|
||||
private final String myPluginName;
|
||||
private String myPluginVersion;
|
||||
private String myFileName;
|
||||
private String myPluginName;
|
||||
private BuildNumber myBuildNumber;
|
||||
private boolean myForceHttps;
|
||||
|
||||
private File myFile;
|
||||
private File myOldFile;
|
||||
private String myDescription;
|
||||
private List<PluginId> myDepends;
|
||||
private IdeaPluginDescriptor myDescriptor;
|
||||
private boolean myForceHttps;
|
||||
|
||||
private PluginDownloader(@NotNull String pluginId,
|
||||
@NotNull String pluginUrl,
|
||||
@Nullable String pluginVersion,
|
||||
@Nullable String fileName,
|
||||
@Nullable String pluginName,
|
||||
@Nullable String pluginVersion,
|
||||
@Nullable BuildNumber buildNumber) {
|
||||
myPluginId = pluginId;
|
||||
myPluginUrl = pluginUrl;
|
||||
myPluginVersion = pluginVersion;
|
||||
myFileName = fileName;
|
||||
myPluginName = pluginName;
|
||||
myBuildNumber = buildNumber;
|
||||
}
|
||||
@@ -90,18 +87,8 @@ public class PluginDownloader {
|
||||
return myPluginVersion;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
if (myFileName == null) {
|
||||
myFileName = myPluginUrl.substring(myPluginUrl.lastIndexOf('/') + 1);
|
||||
}
|
||||
return myFileName;
|
||||
}
|
||||
|
||||
public String getPluginName() {
|
||||
if (myPluginName == null) {
|
||||
myPluginName = FileUtil.getNameWithoutExtension(getFileName());
|
||||
}
|
||||
return myPluginName;
|
||||
return myPluginName != null ? myPluginName : myPluginId;
|
||||
}
|
||||
|
||||
public BuildNumber getBuildNumber() {
|
||||
@@ -260,11 +247,8 @@ public class PluginDownloader {
|
||||
public File process(@NotNull HttpRequests.Request request) throws IOException {
|
||||
request.saveToFile(file, indicator);
|
||||
|
||||
if (myFileName == null) {
|
||||
myFileName = guessFileName(request.getConnection(), file);
|
||||
}
|
||||
|
||||
File newFile = new File(file.getParentFile(), myFileName);
|
||||
String fileName = guessFileName(request.getConnection(), file);
|
||||
File newFile = new File(file.getParentFile(), fileName);
|
||||
FileUtil.rename(file, newFile);
|
||||
return newFile;
|
||||
}
|
||||
@@ -316,9 +300,9 @@ public class PluginDownloader {
|
||||
@Nullable String host,
|
||||
@Nullable BuildNumber buildNumber) throws IOException {
|
||||
try {
|
||||
PluginId id = descriptor.getPluginId();
|
||||
String url = getUrl(descriptor, host, buildNumber, id);
|
||||
PluginDownloader downloader = new PluginDownloader(id.getIdString(), url, descriptor.getVersion(), null, descriptor.getName(), null);
|
||||
String url = getUrl(descriptor, host, buildNumber);
|
||||
String id = descriptor.getPluginId().getIdString();
|
||||
PluginDownloader downloader = new PluginDownloader(id, url, descriptor.getName(), descriptor.getVersion(), buildNumber);
|
||||
downloader.setDescriptor(descriptor);
|
||||
downloader.setDescription(descriptor.getDescription());
|
||||
downloader.setDepends(((PluginNode)descriptor).getDepends());
|
||||
@@ -332,8 +316,7 @@ public class PluginDownloader {
|
||||
@NotNull
|
||||
private static String getUrl(@NotNull IdeaPluginDescriptor descriptor,
|
||||
@Nullable String host,
|
||||
@Nullable BuildNumber buildNumber,
|
||||
PluginId id) throws URISyntaxException, MalformedURLException {
|
||||
@Nullable BuildNumber buildNumber) throws URISyntaxException, MalformedURLException {
|
||||
if (host != null && descriptor instanceof PluginNode) {
|
||||
String url = ((PluginNode)descriptor).getDownloadUrl();
|
||||
return new URI(url).isAbsolute() ? url : new URL(new URL(host), url).toExternalForm();
|
||||
@@ -350,7 +333,7 @@ public class PluginDownloader {
|
||||
|
||||
URIBuilder uriBuilder = new URIBuilder(appInfo.getPluginsDownloadUrl());
|
||||
uriBuilder.addParameter("action", "download");
|
||||
uriBuilder.addParameter("id", id.getIdString());
|
||||
uriBuilder.addParameter("id", descriptor.getPluginId().getIdString());
|
||||
uriBuilder.addParameter("build", buildNumberAsString);
|
||||
uriBuilder.addParameter("uuid", uuid);
|
||||
return uriBuilder.toString();
|
||||
|
||||
Reference in New Issue
Block a user