forked from forgejo/forgejo
Git LFS lock api (#2938)
* Implement routes * move to api/sdk and create model * Implement add + list * List return 200 empty list no 404 * Add verify lfs lock api * Add delete and start implementing auth control * Revert to code.gitea.io/sdk/gitea vendor * Apply needed check for all lfs locks route * Add simple tests * fix lint * Improve tests * Add delete test + fix * Add lfs ascii header * Various fixes from review + remove useless code + add more corner case testing * Remove repo link since only id is needed. Save a little of memory and cpu time. * Improve tests * Use TEXT column format for path + test * fix mispell * Use NewRequestWithJSON for POST tests * Clean path * Improve DB format * Revert uniquess repoid+path * (Re)-setup uniqueness + max path length * Fixed TEXT in place of VARCHAR * Settle back to maximum VARCHAR(3072) * Let place for repoid in key * Let place for repoid in key * Let place for repoid in key * Revert back
This commit is contained in:
parent
6ad4990a65
commit
d99f4ab003
9 changed files with 638 additions and 16 deletions
|
@ -506,6 +506,63 @@ func (err ErrLastOrgOwner) Error() string {
|
|||
return fmt.Sprintf("user is the last member of owner team [uid: %d]", err.UID)
|
||||
}
|
||||
|
||||
//.____ ____________________
|
||||
//| | \_ _____/ _____/
|
||||
//| | | __) \_____ \
|
||||
//| |___| \ / \
|
||||
//|_______ \___ / /_______ /
|
||||
// \/ \/ \/
|
||||
|
||||
// ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error.
|
||||
type ErrLFSLockNotExist struct {
|
||||
ID int64
|
||||
RepoID int64
|
||||
Path string
|
||||
}
|
||||
|
||||
// IsErrLFSLockNotExist checks if an error is a ErrLFSLockNotExist.
|
||||
func IsErrLFSLockNotExist(err error) bool {
|
||||
_, ok := err.(ErrLFSLockNotExist)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err ErrLFSLockNotExist) Error() string {
|
||||
return fmt.Sprintf("lfs lock does not exist [id: %d, rid: %d, path: %s]", err.ID, err.RepoID, err.Path)
|
||||
}
|
||||
|
||||
// ErrLFSLockUnauthorizedAction represents a "LFSLockUnauthorizedAction" kind of error.
|
||||
type ErrLFSLockUnauthorizedAction struct {
|
||||
RepoID int64
|
||||
UserName string
|
||||
Action string
|
||||
}
|
||||
|
||||
// IsErrLFSLockUnauthorizedAction checks if an error is a ErrLFSLockUnauthorizedAction.
|
||||
func IsErrLFSLockUnauthorizedAction(err error) bool {
|
||||
_, ok := err.(ErrLFSLockUnauthorizedAction)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err ErrLFSLockUnauthorizedAction) Error() string {
|
||||
return fmt.Sprintf("User %s doesn't have rigth to %s for lfs lock [rid: %d]", err.UserName, err.Action, err.RepoID)
|
||||
}
|
||||
|
||||
// ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error.
|
||||
type ErrLFSLockAlreadyExist struct {
|
||||
RepoID int64
|
||||
Path string
|
||||
}
|
||||
|
||||
// IsErrLFSLockAlreadyExist checks if an error is a ErrLFSLockAlreadyExist.
|
||||
func IsErrLFSLockAlreadyExist(err error) bool {
|
||||
_, ok := err.(ErrLFSLockAlreadyExist)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err ErrLFSLockAlreadyExist) Error() string {
|
||||
return fmt.Sprintf("lfs lock already exists [rid: %d, path: %s]", err.RepoID, err.Path)
|
||||
}
|
||||
|
||||
// __________ .__ __
|
||||
// \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
|
||||
// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue