diff options
author | David Svantesson <davidsvantesson@gmail.com> | 2019-11-02 08:37:05 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-11-02 15:37:05 +0800 |
commit | 232340f5e3ebe61787021bebea01fd755513c72b (patch) | |
tree | 513182b15c4d977bc64dcabafddd536eab4a8bbc /models | |
parent | 9d663dfde68f4f3fd6af302aad47439adb1076ae (diff) | |
download | gitea-232340f5e3ebe61787021bebea01fd755513c72b.tar.gz gitea-232340f5e3ebe61787021bebea01fd755513c72b.zip |
Prevent upload (overwrite) of lfs locked file (#8769)
* Check if file is locked on upload file commit.
* Better user message if file is locked.
* Check lfs lock before creating temporary repository. fix some errors.
* move lines
* Add comment that enabled setting is checked.
Diffstat (limited to 'models')
-rw-r--r-- | models/error.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go index 995617e83b..505df28868 100644 --- a/models/error.go +++ b/models/error.go @@ -647,6 +647,23 @@ func (err ErrLFSLockAlreadyExist) Error() string { return fmt.Sprintf("lfs lock already exists [rid: %d, path: %s]", err.RepoID, err.Path) } +// ErrLFSFileLocked represents a "LFSFileLocked" kind of error. +type ErrLFSFileLocked struct { + RepoID int64 + Path string + UserName string +} + +// IsErrLFSFileLocked checks if an error is a ErrLFSFileLocked. +func IsErrLFSFileLocked(err error) bool { + _, ok := err.(ErrLFSFileLocked) + return ok +} + +func (err ErrLFSFileLocked) Error() string { + return fmt.Sprintf("File is lfs locked [repo: %d, locked by: %s, path: %s]", err.RepoID, err.UserName, err.Path) +} + // __________ .__ __ // \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__. // | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | | |