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

Method extract

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

Source from the content-addressed store, hash-verified

190}
191
192func (d *Alias) extract(ctx context.Context, dst, sub string, args model.ArchiveInnerArgs) (*model.Link, error) {
193 reqPath := stdpath.Join(dst, sub)
194 storage, reqActualPath, err := op.GetStorageAndActualPath(reqPath)
195 if err != nil {
196 return nil, err
197 }
198 if _, ok := storage.(driver.ArchiveReader); ok {
199 if _, ok := storage.(*Alias); !ok && !args.Redirect {
200 link, _, err := op.DriverExtract(ctx, storage, reqActualPath, args)
201 return link, err
202 }
203 _, err = fs.Get(ctx, reqPath, &fs.GetArgs{NoLog: true})
204 if err != nil {
205 return nil, err
206 }
207 if common.ShouldProxy(storage, stdpath.Base(sub)) {
208 link := &model.Link{
209 URL: fmt.Sprintf("%s/ap%s?inner=%s&pass=%s&sign=%s",
210 common.GetApiUrl(args.HttpReq),
211 utils.EncodePath(reqPath, true),
212 utils.EncodePath(args.InnerPath, true),
213 url.QueryEscape(args.Password),
214 sign.SignArchive(reqPath)),
215 }
216 if args.HttpReq != nil && d.ProxyRange {
217 link.RangeReadCloser = common.NoProxyRange
218 }
219 return link, nil
220 }
221 link, _, err := op.DriverExtract(ctx, storage, reqActualPath, args)
222 return link, err
223 }
224 return nil, errs.NotImplement
225}

Callers 1

ExtractMethod · 0.95

Calls 7

GetStorageAndActualPathFunction · 0.92
DriverExtractFunction · 0.92
GetFunction · 0.92
ShouldProxyFunction · 0.92
GetApiUrlFunction · 0.92
EncodePathFunction · 0.92
SignArchiveFunction · 0.92

Tested by

no test coverage detected