@@ -210,25 +210,29 @@ class DevChatToolWindowFactory : ToolWindowFactory, DumbAware, Disposable {
210210 devChatService.pythonReady = true
211211 }
212212
213- private suspend fun installWorkflows (): Boolean {
214- Log .info(" Start checking and copying workflows files" )
215- val workflowMericoDir = File (PathUtils .workflowMericoPath)
216- var updatePublicWorkflows = CONFIG [" update_public_workflow" ]
217- val overwrite = devChatVersion != DevChatState .instance.lastVersion
218-
219- var workflowCopied = false ;
220- if ((overwrite && updatePublicWorkflows == false ) || ! workflowMericoDir.exists() || ! workflowMericoDir.isDirectory || workflowMericoDir.listFiles()?.isEmpty() == true ) {
221- Log .info(" Workflow Merico directory is missing or empty. Creating and populating it." )
222- PathUtils .copyResourceDirToPath(" /workflows" , PathUtils .workflowPath, true )
223- workflowCopied = true ;
224- } else {
225- Log .info(" Workflow Merico directory exists and is not empty. Skipping copy." )
213+ private suspend fun installWorkflows (): Boolean {
214+ Log .info(" Start checking and copying workflows files" )
215+ val workflowMericoDir = File (PathUtils .workflowMericoPath)
216+ var updatePublicWorkflows = CONFIG [" update_public_workflow" ]
217+ val overwrite = devChatVersion != DevChatState .instance.lastVersion
218+
219+ var workflowCopied = false ;
220+ if ((overwrite && updatePublicWorkflows == false ) || ! workflowMericoDir.exists() || ! workflowMericoDir.isDirectory || workflowMericoDir.listFiles()?.isEmpty() == true ) {
221+ Log .info(" Workflow Merico directory is missing or empty. Creating and populating it." )
222+ // 安全删除:先检查是否存在
223+ if (workflowMericoDir.exists()) {
224+ workflowMericoDir.deleteRecursively()
226225 }
227-
228- Log .info(" Finished checking and copying workflows files" )
229- return workflowCopied;
226+ PathUtils .copyResourceDirToPath(" /workflows" , PathUtils .workflowPath, true )
227+ workflowCopied = true ;
228+ } else {
229+ Log .info(" Workflow Merico directory exists and is not empty. Skipping copy." )
230230 }
231231
232+ Log .info(" Finished checking and copying workflows files" )
233+ return workflowCopied;
234+ }
235+
232236 private suspend fun installTools () {
233237 val overwrite = devChatVersion != DevChatState .instance.lastVersion
234238 Log .info(" start to copy tools files" )
0 commit comments