-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Prevent upload (overwrite) of lfs locked file #8769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9f8fe47
c394d7f
45e8a7e
1610d7f
00efc08
50fcc02
93346e0
8396c7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,23 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep | |
return fmt.Errorf("GetUploadsByUUIDs [uuids: %v]: %v", opts.Files, err) | ||
} | ||
|
||
names := make([]string, len(uploads)) | ||
infos := make([]uploadInfo, len(uploads)) | ||
for i, upload := range uploads { | ||
// Check file is not lfs locked, will return nil if lock setting not enabled | ||
filepath := path.Join(opts.TreePath, upload.Name) | ||
lfsLock, err := repo.GetTreePathLock(filepath) | ||
davidsvantesson marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I missed this earlier - you should only check LFS Locks if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actually in GetTreePathLock, but I am not sure if it is a good design. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok just add a comment above this line to say that if LFS is off then this will return nil. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should probably be a code refactoring regarding GetTreePathLock, but I went for the easy way now and only added a code comment. |
||
if err != nil { | ||
return err | ||
} | ||
if lfsLock != nil && lfsLock.OwnerID != doer.ID { | ||
return models.ErrLFSFileLocked{RepoID: repo.ID, Path: filepath, UserName: lfsLock.Owner.Name} | ||
} | ||
|
||
names[i] = upload.Name | ||
infos[i] = uploadInfo{upload: upload} | ||
} | ||
|
||
t, err := NewTemporaryUploadRepository(repo) | ||
if err != nil { | ||
return err | ||
|
@@ -67,13 +84,6 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep | |
return err | ||
} | ||
|
||
names := make([]string, len(uploads)) | ||
infos := make([]uploadInfo, len(uploads)) | ||
for i, upload := range uploads { | ||
names[i] = upload.Name | ||
infos[i] = uploadInfo{upload: upload} | ||
} | ||
|
||
var filename2attribute2info map[string]map[string]string | ||
if setting.LFS.StartServer { | ||
filename2attribute2info, err = t.CheckAttribute("filter", names...) | ||
|
Uh oh!
There was an error while loading. Please reload this page.