when clearing target storage, do not clear src-out mapping which is handled in a special way

This commit is contained in:
Eugene Zhuravlev
2012-11-25 19:27:05 +01:00
parent bd9a1483cf
commit e19ad35e5b
@@ -57,13 +57,17 @@ public class BuildDataManager implements StorageOwner {
synchronized (mySourceToOutputLock) {
mapping = mySourceToOutputs.get(target);
if (mapping == null) {
mapping = new SourceToOutputMappingImpl(new File(myDataPaths.getTargetDataRoot(target), "src-out" + File.separator + "data"));
mapping = new SourceToOutputMappingImpl(new File(getSourceToOutputMapRoot(target), "data"));
mySourceToOutputs.put(target, mapping);
}
}
return mapping;
}
private File getSourceToOutputMapRoot(BuildTarget<?> target) {
return new File(myDataPaths.getTargetDataRoot(target), "src-out");
}
@NotNull
public <S extends StorageOwner> S getStorage(@NotNull BuildTarget<?> target, @NotNull StorageProvider<S> provider) throws IOException {
synchronized (myTargetStoragesLock) {
@@ -94,17 +98,16 @@ public class BuildDataManager implements StorageOwner {
}
}
finally {
try {
synchronized (mySourceToOutputLock) {
SourceToOutputMappingImpl mapping = mySourceToOutputs.remove(target);
if (mapping != null) {
mapping.close();
// delete all data except src-out mapping which is cleaned in a special way
final File[] targetData = myDataPaths.getTargetDataRoot(target).listFiles();
if (targetData != null) {
final File srcOutputMapRoot = getSourceToOutputMapRoot(target);
for (File dataFile : targetData) {
if (!FileUtil.filesEqual(dataFile, srcOutputMapRoot)) {
FileUtil.delete(dataFile);
}
}
}
finally {
FileUtil.delete(myDataPaths.getTargetDataRoot(target));
}
}
}