do not use project name to compute system cache file name, base dir name is enough

This commit is contained in:
Vladimir Krivosheev
2017-05-02 14:41:02 +02:00
parent c080817c92
commit 4a7f75c4d3
4 changed files with 16 additions and 6 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -91,6 +91,7 @@ public class CompilerPaths {
}
public static String getCompilerSystemDirectoryName(Project project) {
// todo: use ProjectKt.getSystemCacheFileName()
return ProjectUtilCore.getPresentableName(project) + "." + project.getLocationHash();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.project.ProjectKt;
import com.intellij.rt.coverage.data.ProjectData;
import com.intellij.util.Alarm;
import com.intellij.util.ArrayUtil;
@@ -144,7 +145,7 @@ public class TestDiscoveryExtension extends RunConfigurationExtension {
@NotNull
public static String baseTestDiscoveryPathForProject(Project project) {
return PathManager.getSystemPath() + File.separator + "testDiscovery" + File.separator + project.getName() + "." + project.getLocationHash();
return PathManager.getSystemPath() + File.separator + "testDiscovery" + File.separator + ProjectKt.getSystemCacheFileName(project, true, ".");
}
private static final Object ourTracesLock = new Object();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@ package com.intellij.framework.detection.impl;
import com.intellij.framework.detection.DetectedFrameworkDescription;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.project.ProjectKt;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.io.DataExternalizer;
@@ -50,7 +50,7 @@ public class DetectedFrameworksData {
public DetectedFrameworksData(Project project) {
myDetectedFrameworks = new MultiMap<>();
File file = new File(FrameworkDetectorRegistryImpl.getDetectionDirPath() + File.separator + FileUtil.sanitizeFileName(project.getName(), false) + "." + project.getLocationHash() +
File file = new File(FrameworkDetectorRegistryImpl.getDetectionDirPath() + File.separator + ProjectKt.getSystemCacheFileName(project, true, ".") +
File.separator + "files");
myNewFiles = new TIntObjectHashMap<>();
try {
@@ -29,6 +29,7 @@ import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.PathUtilRt
import com.intellij.util.io.basicAttributesIfExists
import com.intellij.util.io.exists
import java.nio.file.InvalidPathException
@@ -120,4 +121,11 @@ fun Project.guessProjectDir() : VirtualFile {
}
}
return this.baseDir!!
}
// Use parameters only for migration purposes, once all usages will be migrated, parameters will be removed
@JvmOverloads
fun Project.getSystemCacheFileName(forceNameUse: Boolean = false, hashSeparator: String = "-"): String {
val name = if (!forceNameUse && isDirectoryBased) FileUtil.sanitizeFileName(PathUtilRt.getFileName(basePath), false) else name
return "$name$hashSeparator$locationHash"
}