aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java16
2 files changed, 17 insertions, 1 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java
index 0da1f5d7cae..f5e73f573c9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java
@@ -95,7 +95,7 @@ public class EditionPluginDownloader {
if (url.startsWith("file:")) {
// used for tests
File file = toFile(uri.toURL());
- Files.copy(file.toPath(), tmpDir);
+ Files.copy(file.toPath(), tmpDir.resolve(file.getName()));
} else {
String filename = substringAfterLast(uri.getPath(), "/");
if (!filename.endsWith("." + PLUGIN_EXTENSION)) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java
index 4f7d6498abd..06e0c4675a8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java
@@ -83,6 +83,22 @@ public class EditionPluginDownloaderTest {
assertThat(downloadDir).isDirectory();
assertThat(tmpDir).doesNotExist();
}
+
+ @Test
+ public void download_plugin_to_tmp_with_file_uri() throws IOException, URISyntaxException {
+ File plugin1 = temp.newFile("plugin1.jar");
+ File plugin2 = temp.newFile("plugin2.jar");
+
+ List<Release> releases = ImmutableList.of(createRelease("plugin1", "1.0", plugin1.toURI().toString()),
+ createRelease("plugin2", "1.0", plugin2.toURI().toString()));
+
+ when(updateCenter.findInstallablePlugins("plugins", Version.create(""))).thenReturn(releases);
+ downloader.downloadEditionPlugins(Collections.singleton("plugins"), updateCenter);
+
+ assertThat(logTester.logs()).containsOnly("Downloading plugin: plugin1", "Downloading plugin: plugin2");
+ assertThat(downloadDir).isDirectory();
+ assertThat(tmpDir).doesNotExist();
+ }
@Test
public void dont_write_download_dir_if_download_fails() throws URISyntaxException {