- do not allow set incorrect path

- avoid removing read only files
(cherry picked from commit b480932)
This commit is contained in:
Maxim.Mossienko
2016-06-15 16:08:41 +03:00
committed by Anna Kozlova
parent e183125b99
commit 03e45cc030
2 changed files with 12 additions and 0 deletions
@@ -102,6 +102,9 @@ public class TestDiscoveryIndex implements ProjectComponent {
}
public void setRemoteTestRunDataPath(String path) {
if(!TestInfoHolder.isValidPath(path)) {
path = null;
}
myRemoteTestRunDataController.init(path);
// todo: should we remove our local run data ?
}
@@ -62,6 +62,7 @@ final class TestInfoHolder {
try {
int version = readVersion(versionFile);
if (version != VERSION) {
assert !readOnly;
TestDiscoveryIndex.LOG.info("TestDiscoveryIndex was rewritten due to version change");
deleteAllIndexDataFiles(methodQNameToTestNameFile,
testNameToUsedClassesAndMethodMapFile,
@@ -285,6 +286,14 @@ final class TestInfoHolder {
return myDisposed;
}
public static boolean isValidPath(String path) {
try {
return readVersion(getVersionFile(path)) == VERSION;
} catch (IOException ex) {
return false;
}
}
private static class TestNamesExternalizer implements DataExternalizer<TIntArrayList> {
public void save(@NotNull DataOutput dataOutput, TIntArrayList testNameIds) throws IOException {
for (int testNameId : testNameIds.toNativeArray()) DataInputOutputUtil.writeINT(dataOutput, testNameId);