|
|
@@ -1,6 +1,7 @@
|
|
|
package repo
|
|
|
|
|
|
import (
|
|
|
+ "errors"
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
"path"
|
|
|
@@ -11,7 +12,6 @@ import (
|
|
|
"gogs.io/gogs/internal/conf"
|
|
|
"gogs.io/gogs/internal/context"
|
|
|
"gogs.io/gogs/internal/database"
|
|
|
- "gogs.io/gogs/internal/database/errors"
|
|
|
"gogs.io/gogs/internal/form"
|
|
|
"gogs.io/gogs/internal/gitutil"
|
|
|
"gogs.io/gogs/internal/pathutil"
|
|
|
@@ -26,6 +26,8 @@ const (
|
|
|
tmplEditorUpload = "repo/editor/upload"
|
|
|
)
|
|
|
|
|
|
+var errInternalServerError = errors.New("internal server error")
|
|
|
+
|
|
|
// getParentTreeFields returns list of parent tree names and corresponding tree paths
|
|
|
// based on given tree path.
|
|
|
func getParentTreeFields(treePath string) (treeNames, treePaths []string) {
|
|
|
@@ -278,7 +280,7 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
|
|
|
}); err != nil {
|
|
|
log.Error("Failed to update repo file: %v", err)
|
|
|
c.FormErr("TreePath")
|
|
|
- c.RenderWithErr(c.Tr("repo.editor.fail_to_update_file", f.TreePath, errors.ErrInternalServerError), tmplEditorEdit, &f)
|
|
|
+ c.RenderWithErr(c.Tr("repo.editor.fail_to_update_file", f.TreePath, errInternalServerError), tmplEditorEdit, &f)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -386,7 +388,7 @@ func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
|
|
|
Message: message,
|
|
|
}); err != nil {
|
|
|
log.Error("Failed to delete repo file: %v", err)
|
|
|
- c.RenderWithErr(c.Tr("repo.editor.fail_to_delete_file", c.Repo.TreePath, errors.ErrInternalServerError), tmplEditorDelete, &f)
|
|
|
+ c.RenderWithErr(c.Tr("repo.editor.fail_to_delete_file", c.Repo.TreePath, errInternalServerError), tmplEditorDelete, &f)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -508,7 +510,7 @@ func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
|
|
|
}); err != nil {
|
|
|
log.Error("Failed to upload files: %v", err)
|
|
|
c.FormErr("TreePath")
|
|
|
- c.RenderWithErr(c.Tr("repo.editor.unable_to_upload_files", f.TreePath, errors.ErrInternalServerError), tmplEditorUpload, &f)
|
|
|
+ c.RenderWithErr(c.Tr("repo.editor.unable_to_upload_files", f.TreePath, errInternalServerError), tmplEditorUpload, &f)
|
|
|
return
|
|
|
}
|
|
|
|