2020-01-29 08:55:23 +03:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-27 21:20:29 +03:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-01-29 08:55:23 +03:00
|
|
|
|
|
|
|
package repo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/models"
|
2021-11-24 12:49:20 +03:00
|
|
|
"code.gitea.io/gitea/models/db"
|
2022-03-29 09:29:02 +03:00
|
|
|
"code.gitea.io/gitea/models/organization"
|
2021-11-28 14:58:28 +03:00
|
|
|
"code.gitea.io/gitea/models/perm"
|
2023-06-22 16:08:08 +03:00
|
|
|
access_model "code.gitea.io/gitea/models/perm/access"
|
feat(quota): Quota enforcement
The previous commit laid out the foundation of the quota engine, this
one builds on top of it, and implements the actual enforcement.
Enforcement happens at the route decoration level, whenever possible. In
case of the API, when over quota, a 413 error is returned, with an
appropriate JSON payload. In case of web routes, a 413 HTML page is
rendered with similar information.
This implementation is for a **soft quota**: quota usage is checked
before an operation is to be performed, and the operation is *only*
denied if the user is already over quota. This makes it possible to go
over quota, but has the significant advantage of being practically
implementable within the current Forgejo architecture.
The goal of enforcement is to deny actions that can make the user go
over quota, and allow the rest. As such, deleting things should - in
almost all cases - be possible. A prime exemption is deleting files via
the web ui: that creates a new commit, which in turn increases repo
size, thus, is denied if the user is over quota.
Limitations
-----------
Because we generally work at a route decorator level, and rarely
look *into* the operation itself, `size:repos:public` and
`size:repos:private` are not enforced at this level, the engine enforces
against `size:repos:all`. This will be improved in the future.
AGit does not play very well with this system, because AGit PRs count
toward the repo they're opened against, while in the GitHub-style fork +
pull model, it counts against the fork. This too, can be improved in the
future.
There's very little done on the UI side to guard against going over
quota. What this patch implements, is enforcement, not prevention. The
UI will still let you *try* operations that *will* result in a denial.
Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-07-06 11:30:16 +03:00
|
|
|
quota_model "code.gitea.io/gitea/models/quota"
|
2021-12-10 04:27:50 +03:00
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
2021-11-24 12:49:20 +03:00
|
|
|
user_model "code.gitea.io/gitea/models/user"
|
2020-01-29 08:55:23 +03:00
|
|
|
"code.gitea.io/gitea/modules/graceful"
|
2021-04-09 01:25:57 +03:00
|
|
|
"code.gitea.io/gitea/modules/lfs"
|
2020-01-29 08:55:23 +03:00
|
|
|
"code.gitea.io/gitea/modules/log"
|
2021-11-16 18:25:33 +03:00
|
|
|
base "code.gitea.io/gitea/modules/migration"
|
2020-01-29 08:55:23 +03:00
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
api "code.gitea.io/gitea/modules/structs"
|
|
|
|
"code.gitea.io/gitea/modules/util"
|
2021-01-26 18:36:53 +03:00
|
|
|
"code.gitea.io/gitea/modules/web"
|
2024-02-27 10:12:22 +03:00
|
|
|
"code.gitea.io/gitea/services/context"
|
2022-12-29 05:57:15 +03:00
|
|
|
"code.gitea.io/gitea/services/convert"
|
2021-04-06 22:44:05 +03:00
|
|
|
"code.gitea.io/gitea/services/forms"
|
2021-11-16 18:25:33 +03:00
|
|
|
"code.gitea.io/gitea/services/migrations"
|
2023-09-05 21:37:47 +03:00
|
|
|
notify_service "code.gitea.io/gitea/services/notify"
|
2023-09-06 15:08:51 +03:00
|
|
|
repo_service "code.gitea.io/gitea/services/repository"
|
2020-01-29 08:55:23 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// Migrate migrate remote git repository to gitea
|
2021-01-26 18:36:53 +03:00
|
|
|
func Migrate(ctx *context.APIContext) {
|
2020-01-29 08:55:23 +03:00
|
|
|
// swagger:operation POST /repos/migrate repository repoMigrate
|
|
|
|
// ---
|
|
|
|
// summary: Migrate a remote git repository
|
|
|
|
// consumes:
|
|
|
|
// - application/json
|
|
|
|
// produces:
|
|
|
|
// - application/json
|
|
|
|
// parameters:
|
|
|
|
// - name: body
|
|
|
|
// in: body
|
|
|
|
// schema:
|
2020-09-11 01:29:19 +03:00
|
|
|
// "$ref": "#/definitions/MigrateRepoOptions"
|
2020-01-29 08:55:23 +03:00
|
|
|
// responses:
|
|
|
|
// "201":
|
|
|
|
// "$ref": "#/responses/Repository"
|
|
|
|
// "403":
|
|
|
|
// "$ref": "#/responses/forbidden"
|
2022-04-12 11:13:07 +03:00
|
|
|
// "409":
|
|
|
|
// description: The repository with the same name already exists.
|
feat(quota): Quota enforcement
The previous commit laid out the foundation of the quota engine, this
one builds on top of it, and implements the actual enforcement.
Enforcement happens at the route decoration level, whenever possible. In
case of the API, when over quota, a 413 error is returned, with an
appropriate JSON payload. In case of web routes, a 413 HTML page is
rendered with similar information.
This implementation is for a **soft quota**: quota usage is checked
before an operation is to be performed, and the operation is *only*
denied if the user is already over quota. This makes it possible to go
over quota, but has the significant advantage of being practically
implementable within the current Forgejo architecture.
The goal of enforcement is to deny actions that can make the user go
over quota, and allow the rest. As such, deleting things should - in
almost all cases - be possible. A prime exemption is deleting files via
the web ui: that creates a new commit, which in turn increases repo
size, thus, is denied if the user is over quota.
Limitations
-----------
Because we generally work at a route decorator level, and rarely
look *into* the operation itself, `size:repos:public` and
`size:repos:private` are not enforced at this level, the engine enforces
against `size:repos:all`. This will be improved in the future.
AGit does not play very well with this system, because AGit PRs count
toward the repo they're opened against, while in the GitHub-style fork +
pull model, it counts against the fork. This too, can be improved in the
future.
There's very little done on the UI side to guard against going over
quota. What this patch implements, is enforcement, not prevention. The
UI will still let you *try* operations that *will* result in a denial.
Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-07-06 11:30:16 +03:00
|
|
|
// "413":
|
|
|
|
// "$ref": "#/responses/quotaExceeded"
|
2020-01-29 08:55:23 +03:00
|
|
|
// "422":
|
|
|
|
// "$ref": "#/responses/validationError"
|
|
|
|
|
2021-01-26 18:36:53 +03:00
|
|
|
form := web.GetForm(ctx).(*api.MigrateRepoOptions)
|
|
|
|
|
2022-01-20 20:46:10 +03:00
|
|
|
// get repoOwner
|
2020-09-11 01:29:19 +03:00
|
|
|
var (
|
2021-11-24 12:49:20 +03:00
|
|
|
repoOwner *user_model.User
|
2020-09-11 01:29:19 +03:00
|
|
|
err error
|
|
|
|
)
|
|
|
|
if len(form.RepoOwner) != 0 {
|
2022-05-20 17:08:52 +03:00
|
|
|
repoOwner, err = user_model.GetUserByName(ctx, form.RepoOwner)
|
2020-09-11 01:29:19 +03:00
|
|
|
} else if form.RepoOwnerID != 0 {
|
2022-12-03 05:48:26 +03:00
|
|
|
repoOwner, err = user_model.GetUserByID(ctx, form.RepoOwnerID)
|
2020-09-11 01:29:19 +03:00
|
|
|
} else {
|
2022-03-22 10:03:22 +03:00
|
|
|
repoOwner = ctx.Doer
|
2020-09-11 01:29:19 +03:00
|
|
|
}
|
|
|
|
if err != nil {
|
2021-11-24 12:49:20 +03:00
|
|
|
if user_model.IsErrUserNotExist(err) {
|
2020-09-11 01:29:19 +03:00
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", err)
|
|
|
|
} else {
|
|
|
|
ctx.Error(http.StatusInternalServerError, "GetUser", err)
|
2020-01-29 08:55:23 +03:00
|
|
|
}
|
2020-09-11 01:29:19 +03:00
|
|
|
return
|
2020-01-29 08:55:23 +03:00
|
|
|
}
|
|
|
|
|
2023-05-21 04:50:53 +03:00
|
|
|
if ctx.HasAPIError() {
|
2020-01-29 08:55:23 +03:00
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", ctx.GetErrMsg())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
feat(quota): Quota enforcement
The previous commit laid out the foundation of the quota engine, this
one builds on top of it, and implements the actual enforcement.
Enforcement happens at the route decoration level, whenever possible. In
case of the API, when over quota, a 413 error is returned, with an
appropriate JSON payload. In case of web routes, a 413 HTML page is
rendered with similar information.
This implementation is for a **soft quota**: quota usage is checked
before an operation is to be performed, and the operation is *only*
denied if the user is already over quota. This makes it possible to go
over quota, but has the significant advantage of being practically
implementable within the current Forgejo architecture.
The goal of enforcement is to deny actions that can make the user go
over quota, and allow the rest. As such, deleting things should - in
almost all cases - be possible. A prime exemption is deleting files via
the web ui: that creates a new commit, which in turn increases repo
size, thus, is denied if the user is over quota.
Limitations
-----------
Because we generally work at a route decorator level, and rarely
look *into* the operation itself, `size:repos:public` and
`size:repos:private` are not enforced at this level, the engine enforces
against `size:repos:all`. This will be improved in the future.
AGit does not play very well with this system, because AGit PRs count
toward the repo they're opened against, while in the GitHub-style fork +
pull model, it counts against the fork. This too, can be improved in the
future.
There's very little done on the UI side to guard against going over
quota. What this patch implements, is enforcement, not prevention. The
UI will still let you *try* operations that *will* result in a denial.
Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-07-06 11:30:16 +03:00
|
|
|
if !ctx.CheckQuota(quota_model.LimitSubjectSizeReposAll, repoOwner.ID, repoOwner.Name) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-22 10:03:22 +03:00
|
|
|
if !ctx.Doer.IsAdmin {
|
|
|
|
if !repoOwner.IsOrganization() && ctx.Doer.ID != repoOwner.ID {
|
2020-01-29 08:55:23 +03:00
|
|
|
ctx.Error(http.StatusForbidden, "", "Given user is not an organization.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-09-11 01:29:19 +03:00
|
|
|
if repoOwner.IsOrganization() {
|
2020-01-29 08:55:23 +03:00
|
|
|
// Check ownership of organization.
|
2023-10-03 13:30:41 +03:00
|
|
|
isOwner, err := organization.OrgFromUser(repoOwner).IsOwnedBy(ctx, ctx.Doer.ID)
|
2020-01-29 08:55:23 +03:00
|
|
|
if err != nil {
|
|
|
|
ctx.Error(http.StatusInternalServerError, "IsOwnedBy", err)
|
|
|
|
return
|
|
|
|
} else if !isOwner {
|
|
|
|
ctx.Error(http.StatusForbidden, "", "Given user is not owner of organization.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-06 22:44:05 +03:00
|
|
|
remoteAddr, err := forms.ParseRemoteAddr(form.CloneAddr, form.AuthUsername, form.AuthPassword)
|
2021-03-16 00:52:11 +03:00
|
|
|
if err == nil {
|
2022-03-22 10:03:22 +03:00
|
|
|
err = migrations.IsMigrateURLAllowed(remoteAddr, ctx.Doer)
|
2021-03-16 00:52:11 +03:00
|
|
|
}
|
2020-01-29 08:55:23 +03:00
|
|
|
if err != nil {
|
2021-04-09 01:25:57 +03:00
|
|
|
handleRemoteAddrError(ctx, err)
|
2020-01-29 08:55:23 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-09-11 01:29:19 +03:00
|
|
|
gitServiceType := convert.ToGitServiceType(form.Service)
|
2020-01-29 08:55:23 +03:00
|
|
|
|
2021-09-07 18:49:36 +03:00
|
|
|
if form.Mirror && setting.Mirror.DisableNewPull {
|
|
|
|
ctx.Error(http.StatusForbidden, "MirrorsGlobalDisabled", fmt.Errorf("the site administrator has disabled the creation of new pull mirrors"))
|
2020-06-04 21:06:24 +03:00
|
|
|
return
|
2020-06-04 19:11:28 +03:00
|
|
|
}
|
|
|
|
|
2020-12-21 17:39:41 +03:00
|
|
|
if setting.Repository.DisableMigrations {
|
|
|
|
ctx.Error(http.StatusForbidden, "MigrationsGlobalDisabled", fmt.Errorf("the site administrator has disabled migrations"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-09 01:25:57 +03:00
|
|
|
form.LFS = form.LFS && setting.LFS.StartServer
|
|
|
|
|
|
|
|
if form.LFS && len(form.LFSEndpoint) > 0 {
|
|
|
|
ep := lfs.DetermineEndpoint("", form.LFSEndpoint)
|
|
|
|
if ep == nil {
|
|
|
|
ctx.Error(http.StatusInternalServerError, "", ctx.Tr("repo.migrate.invalid_lfs_endpoint"))
|
|
|
|
return
|
|
|
|
}
|
2022-03-22 10:03:22 +03:00
|
|
|
err = migrations.IsMigrateURLAllowed(ep.String(), ctx.Doer)
|
2021-04-09 01:25:57 +03:00
|
|
|
if err != nil {
|
|
|
|
handleRemoteAddrError(ctx, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-20 20:46:10 +03:00
|
|
|
opts := migrations.MigrateOptions{
|
2020-01-29 08:55:23 +03:00
|
|
|
CloneAddr: remoteAddr,
|
|
|
|
RepoName: form.RepoName,
|
|
|
|
Description: form.Description,
|
|
|
|
Private: form.Private || setting.Repository.ForcePrivate,
|
2020-06-04 19:11:28 +03:00
|
|
|
Mirror: form.Mirror,
|
2021-04-09 01:25:57 +03:00
|
|
|
LFS: form.LFS,
|
|
|
|
LFSEndpoint: form.LFSEndpoint,
|
2020-01-29 08:55:23 +03:00
|
|
|
AuthUsername: form.AuthUsername,
|
|
|
|
AuthPassword: form.AuthPassword,
|
2020-09-11 01:29:19 +03:00
|
|
|
AuthToken: form.AuthToken,
|
2020-01-29 08:55:23 +03:00
|
|
|
Wiki: form.Wiki,
|
|
|
|
Issues: form.Issues,
|
|
|
|
Milestones: form.Milestones,
|
|
|
|
Labels: form.Labels,
|
2023-03-19 09:29:14 +03:00
|
|
|
Comments: form.Issues || form.PullRequests,
|
2020-01-29 08:55:23 +03:00
|
|
|
PullRequests: form.PullRequests,
|
|
|
|
Releases: form.Releases,
|
|
|
|
GitServiceType: gitServiceType,
|
2021-01-03 02:47:47 +03:00
|
|
|
MirrorInterval: form.MirrorInterval,
|
2020-01-29 08:55:23 +03:00
|
|
|
}
|
|
|
|
if opts.Mirror {
|
|
|
|
opts.Issues = false
|
|
|
|
opts.Milestones = false
|
|
|
|
opts.Labels = false
|
|
|
|
opts.Comments = false
|
|
|
|
opts.PullRequests = false
|
|
|
|
opts.Releases = false
|
|
|
|
}
|
|
|
|
|
2023-09-08 07:51:15 +03:00
|
|
|
repo, err := repo_service.CreateRepositoryDirectly(ctx, ctx.Doer, repoOwner, repo_service.CreateRepoOptions{
|
2020-01-29 08:55:23 +03:00
|
|
|
Name: opts.RepoName,
|
|
|
|
Description: opts.Description,
|
|
|
|
OriginalURL: form.CloneAddr,
|
|
|
|
GitServiceType: gitServiceType,
|
2024-05-20 03:56:45 +03:00
|
|
|
IsPrivate: opts.Private || setting.Repository.ForcePrivate,
|
2020-01-29 08:55:23 +03:00
|
|
|
IsMirror: opts.Mirror,
|
2021-12-10 04:27:50 +03:00
|
|
|
Status: repo_model.RepositoryBeingMigrated,
|
2020-01-29 08:55:23 +03:00
|
|
|
})
|
|
|
|
if err != nil {
|
2024-04-29 11:47:56 +03:00
|
|
|
handleMigrateError(ctx, repoOwner, err)
|
2020-01-29 08:55:23 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
opts.MigrateToRepoID = repo.ID
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
if e := recover(); e != nil {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
fmt.Fprintf(&buf, "Handler crashed with error: %v", log.Stack(2))
|
|
|
|
|
|
|
|
err = errors.New(buf.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
if err == nil {
|
2023-09-05 21:37:47 +03:00
|
|
|
notify_service.MigrateRepository(ctx, ctx.Doer, repoOwner, repo)
|
2020-12-27 06:34:19 +03:00
|
|
|
return
|
2020-01-29 08:55:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if repo != nil {
|
2023-10-18 18:03:10 +03:00
|
|
|
if errDelete := repo_service.DeleteRepositoryDirectly(ctx, ctx.Doer, repo.ID); errDelete != nil {
|
2020-01-29 08:55:23 +03:00
|
|
|
log.Error("DeleteRepository: %v", errDelete)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2022-03-22 10:03:22 +03:00
|
|
|
if repo, err = migrations.MigrateRepository(graceful.GetManager().HammerContext(), ctx.Doer, repoOwner.Name, opts, nil); err != nil {
|
2024-04-29 11:47:56 +03:00
|
|
|
handleMigrateError(ctx, repoOwner, err)
|
2020-01-29 08:55:23 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-09-11 01:29:19 +03:00
|
|
|
log.Trace("Repository migrated: %s/%s", repoOwner.Name, form.RepoName)
|
2023-06-22 16:08:08 +03:00
|
|
|
ctx.JSON(http.StatusCreated, convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeAdmin}))
|
2020-01-29 08:55:23 +03:00
|
|
|
}
|
|
|
|
|
2024-04-29 11:47:56 +03:00
|
|
|
func handleMigrateError(ctx *context.APIContext, repoOwner *user_model.User, err error) {
|
2020-01-29 08:55:23 +03:00
|
|
|
switch {
|
2021-12-12 18:48:20 +03:00
|
|
|
case repo_model.IsErrRepoAlreadyExist(err):
|
2020-01-29 08:55:23 +03:00
|
|
|
ctx.Error(http.StatusConflict, "", "The repository with the same name already exists.")
|
2021-12-12 18:48:20 +03:00
|
|
|
case repo_model.IsErrRepoFilesAlreadyExist(err):
|
2020-09-25 07:09:23 +03:00
|
|
|
ctx.Error(http.StatusConflict, "", "Files already exist for this repository. Adopt them or delete them.")
|
2020-01-29 08:55:23 +03:00
|
|
|
case migrations.IsRateLimitError(err):
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", "Remote visit addressed rate limitation.")
|
|
|
|
case migrations.IsTwoFactorAuthError(err):
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", "Remote visit required two factors authentication.")
|
2021-12-12 18:48:20 +03:00
|
|
|
case repo_model.IsErrReachLimitOfRepo(err):
|
2020-01-29 08:55:23 +03:00
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("You have already reached your limit of %d repositories.", repoOwner.MaxCreationLimit()))
|
2021-11-24 12:49:20 +03:00
|
|
|
case db.IsErrNameReserved(err):
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("The username '%s' is reserved.", err.(db.ErrNameReserved).Name))
|
|
|
|
case db.IsErrNameCharsNotAllowed(err):
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("The username '%s' contains invalid characters.", err.(db.ErrNameCharsNotAllowed).Name))
|
|
|
|
case db.IsErrNamePatternNotAllowed(err):
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("The pattern '%s' is not allowed in a username.", err.(db.ErrNamePatternNotAllowed).Pattern))
|
2021-03-16 00:52:11 +03:00
|
|
|
case models.IsErrInvalidCloneAddr(err):
|
2020-11-29 03:37:58 +03:00
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", err)
|
2021-01-21 22:33:58 +03:00
|
|
|
case base.IsErrNotSupported(err):
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", err)
|
2020-01-29 08:55:23 +03:00
|
|
|
default:
|
2022-03-31 05:25:40 +03:00
|
|
|
err = util.SanitizeErrorCredentialURLs(err)
|
2020-01-29 08:55:23 +03:00
|
|
|
if strings.Contains(err.Error(), "Authentication failed") ||
|
|
|
|
strings.Contains(err.Error(), "Bad credentials") ||
|
|
|
|
strings.Contains(err.Error(), "could not read Username") {
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("Authentication failed: %v.", err))
|
|
|
|
} else if strings.Contains(err.Error(), "fatal:") {
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("Migration failed: %v.", err))
|
|
|
|
} else {
|
|
|
|
ctx.Error(http.StatusInternalServerError, "MigrateRepository", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-09 01:25:57 +03:00
|
|
|
|
|
|
|
func handleRemoteAddrError(ctx *context.APIContext, err error) {
|
|
|
|
if models.IsErrInvalidCloneAddr(err) {
|
|
|
|
addrErr := err.(*models.ErrInvalidCloneAddr)
|
|
|
|
switch {
|
|
|
|
case addrErr.IsURLError:
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", err)
|
|
|
|
case addrErr.IsPermissionDenied:
|
|
|
|
if addrErr.LocalPath {
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", "You are not allowed to import local repositories.")
|
|
|
|
} else {
|
2021-11-20 12:34:05 +03:00
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", "You can not import from disallowed hosts.")
|
2021-04-09 01:25:57 +03:00
|
|
|
}
|
|
|
|
case addrErr.IsInvalidPath:
|
|
|
|
ctx.Error(http.StatusUnprocessableEntity, "", "Invalid local path, it does not exist or not a directory.")
|
|
|
|
default:
|
|
|
|
ctx.Error(http.StatusInternalServerError, "ParseRemoteAddr", "Unknown error type (ErrInvalidCloneAddr): "+err.Error())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ctx.Error(http.StatusInternalServerError, "ParseRemoteAddr", err)
|
|
|
|
}
|
|
|
|
}
|