@@ -367,6 +367,10 @@ func (ep *embeddingProcessService) uploadFilePathFailed(event *model.Event, uplo
367367 }
368368 delete (codebaseEmbeddingConfig .HashTree , filePath )
369369 delete (codebaseEmbeddingConfig .SyncFiles , filePath )
370+ if event .EventType == model .EventTypeRenameFile {
371+ delete (codebaseEmbeddingConfig .HashTree , event .SourceFilePath )
372+ delete (codebaseEmbeddingConfig .SyncFiles , event .SourceFilePath )
373+ }
370374 if utils .IsUnauthorizedError (uploadErr ) {
371375 codebaseEmbeddingConfig .FailedFiles [filePath ] = errs .ErrAuthenticationFailed
372376 } else if utils .IsTooManyRequestsError (uploadErr ) {
@@ -423,12 +427,14 @@ func (ep *embeddingProcessService) CleanWorkspaceFilePath(ctx context.Context, f
423427 }
424428
425429 // 根据事件类型处理不同的文件路径
430+ filePath := event .SourceFilePath
426431 var filePaths []string
427432 switch event .EventType {
428433 case model .EventTypeAddFile , model .EventTypeModifyFile , model .EventTypeDeleteFile :
429434 filePaths = []string {event .SourceFilePath }
430435 case model .EventTypeRenameFile :
431436 filePaths = []string {event .SourceFilePath , event .TargetFilePath }
437+ filePath = event .TargetFilePath
432438 default :
433439 ep .logger .Warn ("unsupported event type for cleaning filepath: %d" , event .EventType )
434440 return nil
@@ -464,17 +470,13 @@ func (ep *embeddingProcessService) CleanWorkspaceFilePath(ctx context.Context, f
464470
465471 // 从SyncFiles中添加对应的文件路径
466472 if codebaseEmbeddingConfig .SyncFiles != nil {
467- for _ , filePath := range filePaths {
468- if oldHash , exists := codebaseEmbeddingConfig .SyncFiles [filePath ]; ! exists || oldHash != fileStatus .Hash {
469- codebaseEmbeddingConfig .SyncFiles [filePath ] = fileStatus .Hash
470- updated = true
471- }
473+ if oldHash , exists := codebaseEmbeddingConfig .SyncFiles [filePath ]; ! exists || oldHash != fileStatus .Hash {
474+ codebaseEmbeddingConfig .SyncFiles [filePath ] = fileStatus .Hash
475+ updated = true
472476 }
473477 } else {
474478 codebaseEmbeddingConfig .SyncFiles = make (map [string ]string )
475- for _ , filePath := range filePaths {
476- codebaseEmbeddingConfig .SyncFiles [filePath ] = fileStatus .Hash
477- }
479+ codebaseEmbeddingConfig .SyncFiles [filePath ] = fileStatus .Hash
478480 updated = true
479481 }
480482
0 commit comments