MCPcopy
hub / github.com/AlistGo/alist / Init

Method Init

drivers/gitee/driver.go:34–60  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

32}
33
34func (d *Gitee) Init(ctx context.Context) error {
35 d.RootFolderPath = utils.FixAndCleanPath(d.RootFolderPath)
36 d.Endpoint = strings.TrimSpace(d.Endpoint)
37 if d.Endpoint == "" {
38 d.Endpoint = "https://gitee.com/api/v5"
39 }
40 d.Endpoint = strings.TrimSuffix(d.Endpoint, "/")
41 d.Owner = strings.TrimSpace(d.Owner)
42 d.Repo = strings.TrimSpace(d.Repo)
43 d.Token = strings.TrimSpace(d.Token)
44 d.DownloadProxy = strings.TrimSpace(d.DownloadProxy)
45 if d.Owner == "" || d.Repo == "" {
46 return errors.New("owner and repo are required")
47 }
48 d.client = base.NewRestyClient().
49 SetBaseURL(d.Endpoint).
50 SetHeader("Accept", "application/json")
51 repo, err := d.getRepo()
52 if err != nil {
53 return err
54 }
55 d.Ref = strings.TrimSpace(d.Ref)
56 if d.Ref == "" {
57 d.Ref = repo.DefaultBranch
58 }
59 return nil
60}
61
62func (d *Gitee) Drop(ctx context.Context) error {
63 return nil

Callers

nothing calls this directly

Calls 4

getRepoMethod · 0.95
FixAndCleanPathFunction · 0.92
NewRestyClientFunction · 0.92
SetHeaderMethod · 0.80

Tested by

no test coverage detected