mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not delete output files corresponding to non-existing sources, if these outputs are already associated with existing sources from other modules that have been already compiled: part 2: correctly clean the mapping when removing outputs corresponding to changed sources
This commit is contained in:
@@ -169,9 +169,12 @@ public class BuildOperations {
|
||||
final Collection<String> outputs = srcToOut.getOutputs(srcPath);
|
||||
if (outputs != null) {
|
||||
final boolean shouldPruneOutputDirs = target instanceof ModuleBasedTarget;
|
||||
final List<String> deletedForThisSource = new ArrayList<String>(outputs.size());
|
||||
for (String output : outputs) {
|
||||
deleteRecursively(output, deletedPaths, shouldPruneOutputDirs ? dirsToDelete : null);
|
||||
deleteRecursively(output, deletedForThisSource, shouldPruneOutputDirs ? dirsToDelete : null);
|
||||
}
|
||||
deletedPaths.addAll(deletedForThisSource);
|
||||
dataManager.getOutputToSourceRegistry().removeMapping(deletedForThisSource, srcPath);
|
||||
Set<File> cleaned = cleanedSources.get(target);
|
||||
if (cleaned == null) {
|
||||
cleaned = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
|
||||
@@ -440,9 +440,7 @@ public class BuildDataManager implements StorageOwner {
|
||||
myDelegate.remove(srcPath);
|
||||
}
|
||||
finally {
|
||||
for (String output : outputs) {
|
||||
myOutputToSourceRegistry.removeMapping(output, srcPath);
|
||||
}
|
||||
myOutputToSourceRegistry.removeMapping(outputs, srcPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-15
@@ -81,25 +81,32 @@ public class OutputToSourceRegistry extends AbstractStateStorage<Integer, TIntHa
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean removeMapping(String outputPath, String sourcePath) throws IOException {
|
||||
final int key = FileUtil.pathHashCode(outputPath);
|
||||
synchronized (myDataLock) {
|
||||
final TIntHashSet state = getState(key);
|
||||
if (state != null) {
|
||||
final int value = FileUtil.pathHashCode(sourcePath);
|
||||
final boolean removed = state.remove(value);
|
||||
if (state.isEmpty()) {
|
||||
remove(key);
|
||||
}
|
||||
else {
|
||||
if (removed) {
|
||||
update(key, state);
|
||||
public void removeMapping(String outputPath, String sourcePath) throws IOException {
|
||||
removeMapping(Collections.singleton(outputPath), sourcePath);
|
||||
}
|
||||
|
||||
public void removeMapping(Collection<String> outputPaths, String sourcePath) throws IOException {
|
||||
if (outputPaths.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final int value = FileUtil.pathHashCode(sourcePath);
|
||||
for (String outputPath : outputPaths) {
|
||||
final int key = FileUtil.pathHashCode(outputPath);
|
||||
synchronized (myDataLock) {
|
||||
final TIntHashSet state = getState(key);
|
||||
if (state != null) {
|
||||
final boolean removed = state.remove(value);
|
||||
if (state.isEmpty()) {
|
||||
remove(key);
|
||||
}
|
||||
else {
|
||||
if (removed) {
|
||||
update(key, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Collection<String> getSafeToDeleteOutputs(Collection<String> outputPaths, String associatedSourcePath) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user