You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

restore_repo.go 995B

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