From c09d1c1cfb5b95ca8bd43ee2ad8ff95d4ee137e6 Mon Sep 17 00:00:00 2001 From: "Dmitry.Krasilschikov" Date: Mon, 25 Jan 2016 19:49:58 +0300 Subject: [PATCH] #RUBY-17510 support of github RailsApp Samples in RubyMine and IDEA --- .../boilerplate/GithubDownloadUtil.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubDownloadUtil.java b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubDownloadUtil.java index 4a3e7cf8584b..a9017a888f83 100644 --- a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubDownloadUtil.java +++ b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubDownloadUtil.java @@ -21,6 +21,7 @@ import java.util.concurrent.Callable; * @author Sergey Simonchik */ public class GithubDownloadUtil { + private static final String PROJECT_GENERATORS = "projectGenerators"; private GithubDownloadUtil() {} @@ -29,9 +30,14 @@ public class GithubDownloadUtil { return "github-" + userName + "-" + repositoryName; } + @NotNull + private static String formatGithubUserName(@NotNull String userName) { + return "github-" + userName; + } + @NotNull public static File getCacheDir(@NotNull String userName, @NotNull String repositoryName) { - File generatorsDir = new File(PathManager.getSystemPath(), "projectGenerators"); + File generatorsDir = new File(PathManager.getSystemPath(), PROJECT_GENERATORS); String dirName = formatGithubRepositoryName(userName, repositoryName); File dir = new File(generatorsDir, dirName); try { @@ -41,6 +47,18 @@ public class GithubDownloadUtil { } } + @NotNull + public static File getUserCacheDir(@NotNull String userName) { + File generatorsDir = new File(PathManager.getSystemPath(), PROJECT_GENERATORS); + String dirName = formatGithubUserName(userName); + File dir = new File(generatorsDir, dirName); + try { + return dir.getCanonicalFile(); + } catch (IOException e) { + return dir; + } + } + public static File findCacheFile(@NotNull String userName, @NotNull String repositoryName, @NotNull String cacheFileName) { File dir = getCacheDir(userName, repositoryName); return new File(dir, cacheFileName);