diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2017-11-28 21:58:37 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-11-28 22:58:37 +0200 |
commit | d99f4ab0035631aacc44739af0a936e59daf83b7 (patch) | |
tree | 607cde54661ad07cb15f1ee5f4d9e836de6ff034 /models/error.go | |
parent | 6ad4990a65462af770e15330da4777ea59bcc5ad (diff) | |
download | gitea-d99f4ab0035631aacc44739af0a936e59daf83b7.tar.gz gitea-d99f4ab0035631aacc44739af0a936e59daf83b7.zip |
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
Diffstat (limited to 'models/error.go')
-rw-r--r-- | models/error.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go index 7ea4e9e2f2..50d9cba171 100644 --- a/models/error.go +++ b/models/error.go @@ -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) +} + // __________ .__ __ // \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__. // | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | | |