|
|
@@ -46,6 +46,14 @@ func FileNotebookCreate(ctx *context.Context, option api.CreateFileNotebookJobOp |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_select_wrong"))) |
|
|
|
return |
|
|
|
} |
|
|
|
if len(getBootFile(option.File, option.OwnerName, option.ProjectName)) > 255 { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_path_too_long"))) |
|
|
|
return |
|
|
|
} |
|
|
|
if len(option.BranchName) > 255 { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_branch_name_too_long"))) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
isNotebookFileExist, _ := isNoteBookFileExist(ctx, option) |
|
|
|
if !isNotebookFileExist { |
|
|
@@ -105,14 +113,29 @@ func FileNotebookCreate(ctx *context.Context, option api.CreateFileNotebookJobOp |
|
|
|
err = downloadCode(sourceRepo, getCodePath(noteBook.JobName, sourceRepo), option.BranchName) |
|
|
|
if err != nil { |
|
|
|
log.Error("download code failed", err) |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("cloudbrain.load_code_failed"))) |
|
|
|
return |
|
|
|
if !strings.Contains(err.Error(), "already exists and is not an empty directory") { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("cloudbrain.load_code_failed"))) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if !isRepoFileMatch(option, noteBook) { |
|
|
|
noteBook.BootFile += ";" + getBootFile(option.File, option.OwnerName, option.ProjectName) |
|
|
|
noteBook.BranchName += ";" + option.BranchName |
|
|
|
noteBook.Description += ";" + getDescription(option) |
|
|
|
if len(noteBook.BootFile)+len(getBootFile(option.File, option.OwnerName, option.ProjectName))+1 <= 255 { |
|
|
|
noteBook.BootFile += ";" + getBootFile(option.File, option.OwnerName, option.ProjectName) |
|
|
|
} else { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("cloudbrain.notebook_path_too_long"))) |
|
|
|
return |
|
|
|
} |
|
|
|
if len(noteBook.BranchName)+len(option.BranchName)+1 <= 255 { |
|
|
|
noteBook.BranchName += ";" + option.BranchName |
|
|
|
} else { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("cloudbrain.notebook_branch_name_too_long"))) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if len(noteBook.Description)+len(getDescription(option))+1 <= 256 { |
|
|
|
noteBook.Description += ";" + getDescription(option) |
|
|
|
} |
|
|
|
|
|
|
|
err := models.UpdateJob(noteBook) |
|
|
|
if err != nil { |
|
|
|