@@ -103,7 +103,12 @@ func (d *Alias) link(ctx context.Context, dst, sub string, args model.LinkArgs)
103
103
if err != nil {
104
104
return nil , err
105
105
}
106
- if _ , ok := storage .(* Alias ); ! ok && ! args .Redirect {
106
+ useRawLink := len (common .GetApiUrl (ctx )) == 0 // ftp、s3
107
+ if ! useRawLink {
108
+ _ , ok := storage .(* Alias )
109
+ useRawLink = ! ok && ! args .Redirect
110
+ }
111
+ if useRawLink {
107
112
link , _ , err := op .Link (ctx , storage , reqActualPath , args )
108
113
return link , err
109
114
}
@@ -114,13 +119,10 @@ func (d *Alias) link(ctx context.Context, dst, sub string, args model.LinkArgs)
114
119
if common .ShouldProxy (storage , stdpath .Base (sub )) {
115
120
link := & model.Link {
116
121
URL : fmt .Sprintf ("%s/p%s?sign=%s" ,
117
- common .GetApiUrl (args . HttpReq ),
122
+ common .GetApiUrl (ctx ),
118
123
utils .EncodePath (reqPath , true ),
119
124
sign .Sign (reqPath )),
120
125
}
121
- if args .HttpReq != nil && d .ProxyRange {
122
- link .RangeReadCloser = common .NoProxyRange
123
- }
124
126
return link , nil
125
127
}
126
128
link , _ , err := op .Link (ctx , storage , reqActualPath , args )
@@ -201,31 +203,24 @@ func (d *Alias) extract(ctx context.Context, dst, sub string, args model.Archive
201
203
if err != nil {
202
204
return nil , err
203
205
}
204
- if _ , ok := storage .(driver.ArchiveReader ); ok {
205
- if _ , ok := storage .(* Alias ); ! ok && ! args .Redirect {
206
- link , _ , err := op .DriverExtract (ctx , storage , reqActualPath , args )
207
- return link , err
208
- }
206
+ if _ , ok := storage .(driver.ArchiveReader ); ! ok {
207
+ return nil , errs .NotImplement
208
+ }
209
+ if args .Redirect && common .ShouldProxy (storage , stdpath .Base (sub )) {
209
210
_ , err = fs .Get (ctx , reqPath , & fs.GetArgs {NoLog : true })
210
211
if err != nil {
211
212
return nil , err
212
213
}
213
- if common .ShouldProxy (storage , stdpath .Base (sub )) {
214
- link := & model.Link {
215
- URL : fmt .Sprintf ("%s/ap%s?inner=%s&pass=%s&sign=%s" ,
216
- common .GetApiUrl (args .HttpReq ),
217
- utils .EncodePath (reqPath , true ),
218
- utils .EncodePath (args .InnerPath , true ),
219
- url .QueryEscape (args .Password ),
220
- sign .SignArchive (reqPath )),
221
- }
222
- if args .HttpReq != nil && d .ProxyRange {
223
- link .RangeReadCloser = common .NoProxyRange
224
- }
225
- return link , nil
214
+ link := & model.Link {
215
+ URL : fmt .Sprintf ("%s/ap%s?inner=%s&pass=%s&sign=%s" ,
216
+ common .GetApiUrl (ctx ),
217
+ utils .EncodePath (reqPath , true ),
218
+ utils .EncodePath (args .InnerPath , true ),
219
+ url .QueryEscape (args .Password ),
220
+ sign .SignArchive (reqPath )),
226
221
}
227
- link , _ , err := op .DriverExtract (ctx , storage , reqActualPath , args )
228
- return link , err
222
+ return link , nil
229
223
}
230
- return nil , errs .NotImplement
224
+ link , _ , err := op .DriverExtract (ctx , storage , reqActualPath , args )
225
+ return link , err
231
226
}
0 commit comments