code.gitea.io/gitea@v1.22.3/modules/private/restore_repo.go (about) 1 // Copyright 2020 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package private 5 6 import ( 7 "context" 8 "fmt" 9 "time" 10 11 "code.gitea.io/gitea/modules/setting" 12 ) 13 14 // RestoreParams structure holds a data for restore repository 15 type RestoreParams struct { 16 RepoDir string 17 OwnerName string 18 RepoName string 19 Units []string 20 Validation bool 21 } 22 23 // RestoreRepo calls the internal RestoreRepo function 24 func RestoreRepo(ctx context.Context, repoDir, ownerName, repoName string, units []string, validation bool) ResponseExtra { 25 reqURL := setting.LocalURL + "api/internal/restore_repo" 26 27 req := newInternalRequest(ctx, reqURL, "POST", RestoreParams{ 28 RepoDir: repoDir, 29 OwnerName: ownerName, 30 RepoName: repoName, 31 Units: units, 32 Validation: validation, 33 }) 34 req.SetTimeout(3*time.Second, 0) // since the request will spend much time, don't timeout 35 return requestJSONClientMsg(req, fmt.Sprintf("Restore repo %s/%s successfully", ownerName, repoName)) 36 }