Commit e369a6b2 authored by Dmitry Trofimov's avatar Dmitry Trofimov
Browse files

Copy prebuilt indices to the writable index folder (PY-26075)

parent 131c0d5c
Showing with 13 additions and 0 deletions
+13 -0
......@@ -24,6 +24,7 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.psi.stubs.*;
import com.intellij.util.indexing.FileContent;
import com.intellij.util.indexing.IndexInfrastructure;
import com.intellij.util.io.PersistentHashMap;
import com.jetbrains.python.psi.PyFileElementType;
import org.jetbrains.annotations.NotNull;
......@@ -55,6 +56,10 @@ public class PyPrebuiltStubsProvider implements PrebuiltStubsProvider, Disposabl
File indexesRoot = findPrebuiltIndexesRoot();
try {
if (indexesRoot != null) {
// we should copy prebuilt indexes to a writable folder
indexesRoot = copyPrebuiltIndexesToIndexRoot(indexesRoot);
// otherwise we can get access denied error, because persistent hash map opens file for read and write
String stubVersion = FileUtil.loadFile(new File(indexesRoot, SDK_STUBS_STORAGE_NAME + ".version"));
int currentVersion = PyFileElementType.INSTANCE.getStubVersion();
......@@ -86,6 +91,14 @@ public class PyPrebuiltStubsProvider implements PrebuiltStubsProvider, Disposabl
}
}
private static File copyPrebuiltIndexesToIndexRoot(File prebuiltIndicesRoot) throws IOException {
File indexRoot = new File(IndexInfrastructure.getPersistentIndexRoot(), "prebuilt");
FileUtil.copyDir(prebuiltIndicesRoot, indexRoot);
return indexRoot;
}
@Nullable
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment