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

Method linkRealFile

drivers/strm/util.go:153–178  ·  view source on GitHub ↗
(ctx context.Context, realPath string, args model.LinkArgs)

Source from the content-addressed store, hash-verified

151}
152
153func (d *Strm) linkRealFile(ctx context.Context, realPath string, args model.LinkArgs) (*model.Link, error) {
154 storage, actualPath, err := op.GetStorageAndActualPath(realPath)
155 if err != nil {
156 return nil, err
157 }
158 if !args.Redirect {
159 link, _, linkErr := op.Link(ctx, storage, actualPath, args)
160 return link, linkErr
161 }
162 obj, err := fs.Get(ctx, realPath, &fs.GetArgs{NoLog: true})
163 if err != nil {
164 return nil, err
165 }
166 if common.ShouldProxy(storage, obj.GetName()) {
167 api := common.GetApiUrl(args.HttpReq)
168 if api == "" {
169 api = strings.TrimSuffix(strings.TrimSpace(d.SiteUrl), "/")
170 }
171 if api == "" {
172 api = common.GetApiUrl(nil)
173 }
174 return &model.Link{URL: fmt.Sprintf("%s/p%s?sign=%s", api, utils.EncodePath(realPath, true), d.generateSign(realPath))}, nil
175 }
176 link, _, linkErr := op.Link(ctx, storage, actualPath, args)
177 return link, linkErr
178}
179
180func (d *Strm) syncLocalDir(ctx context.Context, virtualDir string, objs []model.Obj) {
181 d.syncLocalDirWithMode(ctx, virtualDir, objs, d.normalizedMode)

Callers 2

LinkMethod · 0.95
localPayloadMethod · 0.95

Calls 8

generateSignMethod · 0.95
GetStorageAndActualPathFunction · 0.92
LinkFunction · 0.92
GetFunction · 0.92
ShouldProxyFunction · 0.92
GetApiUrlFunction · 0.92
EncodePathFunction · 0.92
GetNameMethod · 0.65

Tested by

no test coverage detected