Skip to content

Commit

Permalink
mod: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
hetao92 committed Mar 9, 2023
1 parent 183eb8a commit 2895287
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions server/api/studio/internal/service/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/vesoft-inc/go-pkg/middleware"
"github.com/vesoft-inc/nebula-importer/v4/pkg/config"
configbase "github.com/vesoft-inc/nebula-importer/v4/pkg/config/base"
configv3 "github.com/vesoft-inc/nebula-importer/v4/pkg/config/v3"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/service/importer"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/svc"
Expand Down Expand Up @@ -63,7 +62,7 @@ func NewImportService(ctx context.Context, svcCtx *svc.ServiceContext) ImportSer
svcCtx: svcCtx,
}
}
func updateConfig(conf configbase.Configurator, taskDir, uploadDir string) {
func updateConfig(conf config.Configurator, taskDir, uploadDir string) {
confv3 := conf.(*configv3.Config)
if confv3.Log == nil {
confv3.Log = &config.Log{}
Expand Down
6 changes: 4 additions & 2 deletions server/api/studio/internal/service/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ func StartImport(taskID int) (err error) {
GetTaskMgr().AbortTask(taskID)
return
}
task.TaskInfo.TaskStatus = StatusFinished.String()
GetTaskMgr().FinishTask(taskID)
if task.TaskInfo.TaskStatus == StatusProcessing.String() {
task.TaskInfo.TaskStatus = StatusFinished.String()
GetTaskMgr().FinishTask(taskID)
}
signal <- struct{}{}
}()
return nil
Expand Down
8 changes: 4 additions & 4 deletions server/api/studio/internal/service/importer/taskmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"sync"

importConfig "github.com/vesoft-inc/nebula-importer/v4/pkg/config"
importconfig "github.com/vesoft-inc/nebula-importer/v4/pkg/config"
configv3 "github.com/vesoft-inc/nebula-importer/v4/pkg/config/v3"
db "github.com/vesoft-inc/nebula-studio/server/api/studio/internal/model"
"github.com/vesoft-inc/nebula-studio/server/api/studio/pkg/ecode"
Expand Down Expand Up @@ -46,7 +46,7 @@ func CreateNewTaskDir(rootDir string) (string, error) {
func CreateConfigFile(taskdir string, cfgBytes []byte) error {
fileName := "config.yaml"
path := filepath.Join(taskdir, fileName)
config, _ := importConfig.FromBytes(cfgBytes)
config, _ := importconfig.FromBytes(cfgBytes)
confv3 := config.(*configv3.Config)

// erase user information
Expand All @@ -65,7 +65,7 @@ func CreateConfigFile(taskdir string, cfgBytes []byte) error {
return nil
}

func (mgr *TaskMgr) NewTask(host string, user string, taskName string, cfg importConfig.Configurator) (*Task, int, error) {
func (mgr *TaskMgr) NewTask(host string, user string, taskName string, cfg importconfig.Configurator) (*Task, int, error) {
mux.Lock()
defer mux.Unlock()
confv3 := cfg.(*configv3.Config)
Expand Down Expand Up @@ -199,11 +199,11 @@ and then call FinishTask
func (mgr *TaskMgr) StopTask(taskID int) error {
if task, ok := mgr.getTaskFromMap(taskID); ok {
manager := task.Client.Manager
task.TaskInfo.TaskStatus = StatusStoped.String()
err := manager.Stop()
if err != nil {
return errors.New("stop task fail")
}
task.TaskInfo.TaskStatus = StatusStoped.String()
if err := mgr.FinishTask(taskID); err != nil {
return ecode.WithErrorMessage(ecode.ErrInternalServer, err)
}
Expand Down

0 comments on commit 2895287

Please sign in to comment.