2021-06-24 00:12:38 +03:00
|
|
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
2021-09-19 14:49:59 +03:00
|
|
|
"code.gitea.io/gitea/models/db"
|
2021-12-06 10:19:28 +03:00
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
2021-06-24 00:12:38 +03:00
|
|
|
)
|
|
|
|
|
2021-12-06 10:19:28 +03:00
|
|
|
// LoadArchiverRepo loads repository
|
2021-12-10 04:27:50 +03:00
|
|
|
func LoadArchiverRepo(archiver *repo_model.RepoArchiver) (*repo_model.Repository, error) {
|
|
|
|
var repo repo_model.Repository
|
2021-09-23 18:45:36 +03:00
|
|
|
has, err := db.GetEngine(db.DefaultContext).ID(archiver.RepoID).Get(&repo)
|
2021-06-24 00:12:38 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if !has {
|
2021-12-10 04:27:50 +03:00
|
|
|
return nil, repo_model.ErrRepoNotExist{
|
2021-06-24 00:12:38 +03:00
|
|
|
ID: archiver.RepoID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return &repo, nil
|
|
|
|
}
|