Skip to content

Commit ab76784

Browse files
committed
fix(compiler): fix patch execution race condition #100
Ensure patch execution consistency by wrapping in invokeLater to avoid race condition. The commit fixes a race condition in the patch execution process by wrapping the execution logic in `invokeLater`, ensuring consistency and avoiding potential conflicts.
1 parent 9577393 commit ab76784

File tree

1 file changed

+9
-8
lines changed
  • exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec

1 file changed

+9
-8
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/PatchInsCommand.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@ class PatchInsCommand(val myProject: Project, val prop: String, val codeContent:
2121
myReader.parseAllPatches()
2222

2323
val filePatches: MutableList<FilePatch> = myReader.allPatches
24-
val matchedPatches =
25-
MatchPatchPaths(myProject).execute(filePatches, true)
26-
27-
val patchGroups = MultiMap<VirtualFile, AbstractFilePatchInProgress<*>>()
28-
for (patchInProgress in matchedPatches) {
29-
patchGroups.putValue(patchInProgress.base, patchInProgress)
30-
}
3124

3225
ApplicationManager.getApplication().invokeLater {
26+
val matchedPatches =
27+
MatchPatchPaths(myProject).execute(filePatches, true)
28+
29+
val patchGroups = MultiMap<VirtualFile, AbstractFilePatchInProgress<*>>()
30+
for (patchInProgress in matchedPatches) {
31+
patchGroups.putValue(patchInProgress.base, patchInProgress)
32+
}
33+
3334
val additionalInfo = myReader.getAdditionalInfo(ApplyPatchDefaultExecutor.pathsFromGroups(patchGroups))
3435
shelfExecutor.apply(filePatches, patchGroups, null, prop, additionalInfo)
3536
}
3637

37-
return "Patch applied"
38+
return "Patch in Progress..."
3839
}
3940

4041
}

0 commit comments

Comments
 (0)