diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-09-08 23:45:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 23:45:10 +0800 |
commit | 7a5465fc56f79f5fc3c32547c89a80b7ebb24c8f (patch) | |
tree | c663ce5f0f37e13d950384fd76428c422adfb06d /modules/repofiles | |
parent | e4b3f35b8d68d6409a280a8e644759e10b091cb1 (diff) | |
download | gitea-7a5465fc56f79f5fc3c32547c89a80b7ebb24c8f.tar.gz gitea-7a5465fc56f79f5fc3c32547c89a80b7ebb24c8f.zip |
LFS support to be stored on minio (#12518)
* LFS support to be stored on minio
* Fix test
* Fix lint
* Fix lint
* Fix check
* Fix test
* Update documents and add migration for LFS
* Fix some bugs
Diffstat (limited to 'modules/repofiles')
-rw-r--r-- | modules/repofiles/update.go | 9 | ||||
-rw-r--r-- | modules/repofiles/upload.go | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go index d65f61c840..84a3bcb64e 100644 --- a/modules/repofiles/update.go +++ b/modules/repofiles/update.go @@ -20,6 +20,7 @@ import ( "code.gitea.io/gitea/modules/log" repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/modules/structs" pull_service "code.gitea.io/gitea/services/pull" @@ -433,8 +434,12 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up if err != nil { return nil, err } - contentStore := &lfs.ContentStore{BasePath: setting.LFS.ContentPath} - if !contentStore.Exists(lfsMetaObject) { + contentStore := &lfs.ContentStore{ObjectStorage: storage.LFS} + exist, err := contentStore.Exists(lfsMetaObject) + if err != nil { + return nil, err + } + if !exist { if err := contentStore.Put(lfsMetaObject, strings.NewReader(opts.Content)); err != nil { if _, err2 := repo.RemoveLFSMetaObjectByOid(lfsMetaObject.Oid); err2 != nil { return nil, fmt.Errorf("Error whilst removing failed inserted LFS object %s: %v (Prev Error: %v)", lfsMetaObject.Oid, err2, err) diff --git a/modules/repofiles/upload.go b/modules/repofiles/upload.go index eb1379560d..e3ec48ec0f 100644 --- a/modules/repofiles/upload.go +++ b/modules/repofiles/upload.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/storage" ) // UploadRepoFileOptions contains the uploaded repository file options @@ -163,12 +164,16 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep // OK now we can insert the data into the store - there's no way to clean up the store // once it's in there, it's in there. - contentStore := &lfs.ContentStore{BasePath: setting.LFS.ContentPath} + contentStore := &lfs.ContentStore{ObjectStorage: storage.LFS} for _, uploadInfo := range infos { if uploadInfo.lfsMetaObject == nil { continue } - if !contentStore.Exists(uploadInfo.lfsMetaObject) { + exist, err := contentStore.Exists(uploadInfo.lfsMetaObject) + if err != nil { + return cleanUpAfterFailure(&infos, t, err) + } + if !exist { file, err := os.Open(uploadInfo.upload.LocalPath()) if err != nil { return cleanUpAfterFailure(&infos, t, err) |