List<OutputLoadResult> (@NotNull JpsLoaderContext context, @NotNull List<AffectedModule> affectedModules) { File targetDir = new File(PathManager.getPluginTempPath(), JpsCachesLoaderUtil.LOADER_TMP_FOLDER_NAME); if (targetDir.exists()) FileUtil.delete(targetDir); targetDir.mkdirs(); Map<String, AffectedModule> urlToModuleNameMap = affectedModules.stream().collect(Collectors.toMap( module -> myServerUrl + "/" + module.getType() + "/" + module.getName() + "/" + module.getHash(), module -> module)); List<DownloadableFileUrl> descriptions = ContainerUtil.map(urlToModuleNameMap.entrySet(), entry -> new DownloadableFileUrl(entry.getKey(), entry.getValue().getOutPath().getName() + ".zip")); JpsCachesDownloader downloader = new JpsCachesDownloader(descriptions, context.getNettyClient(), context); List<File> downloadedFiles = new ArrayList<>(); try { // Downloading process List<Pair<File, DownloadableFileUrl>> download = downloader.download(targetDir); downloadedFiles = ContainerUtil.map(download, pair -> pair.first); return ContainerUtil.map(download, pair -> { String downloadUrl = pair.second.getDownloadUrl(); return new OutputLoadResult(pair.first, downloadUrl, urlToModuleNameMap.get(downloadUrl)); }); } catch (ProcessCanceledException | IOException e) { //noinspection InstanceofCatchParameter if (e instanceof IOException) LOG.warn("Failed to download JPS compilation outputs", e); if (targetDir.exists()) FileUtil.delete(targetDir); downloadedFiles.forEach(zipFile -> FileUtil.delete(zipFile)); return null; } }