Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:Factory:git-workflow
gitea
gitea-lfs-fallback-to-obs.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gitea-lfs-fallback-to-obs.patch of Package gitea
commit e053ad2fa8be275fb56517c35e6badc434660af0 Author: Stephan Kulow <coolo@suse.de> Date: Fri Sep 2 14:34:34 2022 +0200 Redirect old LFS oids to api.opensuse.org This is very specific to gitea.opensuse.org deployment where we want to avoid copying all the old tar revisions from OBS to git LFS. So if the LFS OID is not on the gitea store, we check the imported historic packages and redirect there. Index: gitea-1.21.9/modules/setting/lfs.go =================================================================== --- gitea-1.21.9.orig/modules/setting/lfs.go +++ gitea-1.21.9/modules/setting/lfs.go @@ -17,6 +17,7 @@ var LFS = struct { HTTPAuthExpiry time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"` MaxFileSize int64 `ini:"LFS_MAX_FILE_SIZE"` LocksPagingNum int `ini:"LFS_LOCKS_PAGING_NUM"` + FallbackToOBS bool `ini:"FALLBACK_TO_OBS"` Storage *Storage }{} Index: gitea-1.21.9/services/lfs/server.go =================================================================== --- gitea-1.21.9.orig/services/lfs/server.go +++ gitea-1.21.9/services/lfs/server.go @@ -246,6 +246,14 @@ func BatchHandler(ctx *context.Context) responseObject = buildObjectResponse(rc, p, false, !exists, err) } else { var err *lfs_module.ObjectError + + if setting.LFS.FallbackToOBS && !exists { + obsresp := obsResponseOrNil(rc, p) + if obsresp != nil { + responseObjects = append(responseObjects, obsresp) + continue + } + } if !exists || meta == nil { err = &lfs_module.ObjectError{ Code: http.StatusNotFound, @@ -438,6 +446,27 @@ func getAuthenticatedRepository(ctx *con return repository } +func obsResponseOrNil(rc *requestContext, pointer lfs_module.Pointer) *lfs_module.ObjectResponse { + url := fmt.Sprintf("http://localhost:9999/check/%s/%d", pointer.Oid, pointer.Size) + resp, err := http.Get(url) + if err != nil { + log.Debug("URL %s returned error", url) + return nil + } + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + if err != nil { + log.Debug("URL %s didn't return body", url) + return nil + } + link := string(body) + rep := &lfs_module.ObjectResponse{Pointer: pointer} + rep.Actions = make(map[string]*lfs_module.Link) + header := make(map[string]string) + rep.Actions["download"] = &lfs_module.Link{Href: link, Header: header} + return rep +} + func buildObjectResponse(rc *requestContext, pointer lfs_module.Pointer, download, upload bool, err *lfs_module.ObjectError) *lfs_module.ObjectResponse { rep := &lfs_module.ObjectResponse{Pointer: pointer} if err != nil {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor