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

Method Delete

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

Source from the content-addressed store, hash-verified

89}
90
91func (c *MirrorSourceComponent) Delete(ctx context.Context, id int64, currentUser string) error {
92 user, err := c.userStore.FindByUsername(ctx, currentUser)
93 if err != nil {
94 return errors.New("user does not exist")
95 }
96 if !user.CanAdmin() {
97 return errors.New("user does not have admin permission")
98 }
99 ms, err := c.msStore.Get(ctx, id)
100 if err != nil {
101 return fmt.Errorf("failed to find mirror source, error: %w", err)
102 }
103 err = c.msStore.Delete(ctx, ms)
104 if err != nil {
105 return fmt.Errorf("failed to delete mirror source, error: %w", err)
106 }
107 return nil
108}

Callers

nothing calls this directly

Calls 3

FindByUsernameMethod · 0.80
CanAdminMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected