MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / Get

Method Get

component/mirror_source.go:43–56  ·  view source on GitHub ↗
(ctx context.Context, id int64, currentUser string)

Source from the content-addressed store, hash-verified

41}
42
43func (c *MirrorSourceComponent) Get(ctx context.Context, id int64, currentUser string) (*database.MirrorSource, error) {
44 user, err := c.userStore.FindByUsername(ctx, currentUser)
45 if err != nil {
46 return nil, errors.New("user does not exist")
47 }
48 if !user.CanAdmin() {
49 return nil, errors.New("user does not have admin permission")
50 }
51 ms, err := c.msStore.Get(ctx, id)
52 if err != nil {
53 return nil, fmt.Errorf("failed to get mirror source, error: %w", err)
54 }
55 return ms, nil
56}
57
58func (c *MirrorSourceComponent) Index(ctx context.Context, currentUser string) ([]database.MirrorSource, error) {
59 user, err := c.userStore.FindByUsername(ctx, currentUser)

Callers 7

CreateMirrorRepoMethod · 0.45
CreateMirrorMethod · 0.45
UpdateMirrorMethod · 0.45
calcFreshnessScoreMethod · 0.45
calcDownloadsScoreMethod · 0.45
DeleteMethod · 0.45
RepoTypeFromContextFunction · 0.45

Calls 2

FindByUsernameMethod · 0.80
CanAdminMethod · 0.45

Tested by

no test coverage detected