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

Method link

drivers/alias/util.go:99–128  ·  view source on GitHub ↗
(ctx context.Context, dst, sub string, args model.LinkArgs)

Source from the content-addressed store, hash-verified

97}
98
99func (d *Alias) link(ctx context.Context, dst, sub string, args model.LinkArgs) (*model.Link, error) {
100 reqPath := stdpath.Join(dst, sub)
101 // 参考 crypt 驱动
102 storage, reqActualPath, err := op.GetStorageAndActualPath(reqPath)
103 if err != nil {
104 return nil, err
105 }
106 if _, ok := storage.(*Alias); !ok && !args.Redirect {
107 link, _, err := op.Link(ctx, storage, reqActualPath, args)
108 return link, err
109 }
110 _, err = fs.Get(ctx, reqPath, &fs.GetArgs{NoLog: true})
111 if err != nil {
112 return nil, err
113 }
114 if common.ShouldProxy(storage, stdpath.Base(sub)) {
115 link := &model.Link{
116 URL: fmt.Sprintf("%s/p%s?sign=%s",
117 common.GetApiUrl(args.HttpReq),
118 utils.EncodePath(reqPath, true),
119 sign.Sign(reqPath)),
120 }
121 if args.HttpReq != nil && d.ProxyRange {
122 link.RangeReadCloser = common.NoProxyRange
123 }
124 return link, nil
125 }
126 link, _, err := op.Link(ctx, storage, reqActualPath, args)
127 return link, err
128}
129
130func (d *Alias) getReqPath(ctx context.Context, obj model.Obj, isParent bool) (*string, error) {
131 root, sub := d.getRootAndPath(obj.GetPath())

Callers 1

LinkMethod · 0.95

Calls 7

GetStorageAndActualPathFunction · 0.92
LinkFunction · 0.92
GetFunction · 0.92
ShouldProxyFunction · 0.92
GetApiUrlFunction · 0.92
EncodePathFunction · 0.92
SignFunction · 0.92

Tested by

no test coverage detected