@@ -78,10 +78,18 @@ func (d *Alias) Get(ctx context.Context, path string) (model.Obj, error) {
78
78
return nil , errs .ObjectNotFound
79
79
}
80
80
for _ , dst := range dsts {
81
- obj , err := d . get (ctx , path , dst , sub )
82
- if err = = nil {
83
- return obj , nil
81
+ obj , err := fs . Get (ctx , stdpath . Join ( dst , sub ), & fs. GetArgs { NoLog : true } )
82
+ if err ! = nil {
83
+ continue
84
84
}
85
+ return & model.Object {
86
+ Path : path ,
87
+ Name : obj .GetName (),
88
+ Size : obj .GetSize (),
89
+ Modified : obj .ModTime (),
90
+ IsFolder : obj .IsDir (),
91
+ HashInfo : obj .GetHash (),
92
+ }, nil
85
93
}
86
94
return nil , errs .ObjectNotFound
87
95
}
@@ -99,7 +107,27 @@ func (d *Alias) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
99
107
var objs []model.Obj
100
108
fsArgs := & fs.ListArgs {NoLog : true , Refresh : args .Refresh }
101
109
for _ , dst := range dsts {
102
- tmp , err := d .list (ctx , dst , sub , fsArgs )
110
+ tmp , err := fs .List (ctx , stdpath .Join (dst , sub ), fsArgs )
111
+ if err == nil {
112
+ tmp , err = utils .SliceConvert (tmp , func (obj model.Obj ) (model.Obj , error ) {
113
+ thumb , ok := model .GetThumb (obj )
114
+ objRes := model.Object {
115
+ Name : obj .GetName (),
116
+ Size : obj .GetSize (),
117
+ Modified : obj .ModTime (),
118
+ IsFolder : obj .IsDir (),
119
+ }
120
+ if ! ok {
121
+ return & objRes , nil
122
+ }
123
+ return & model.ObjThumb {
124
+ Object : objRes ,
125
+ Thumbnail : model.Thumbnail {
126
+ Thumbnail : thumb ,
127
+ },
128
+ }, nil
129
+ })
130
+ }
103
131
if err == nil {
104
132
objs = append (objs , tmp ... )
105
133
}
@@ -113,43 +141,50 @@ func (d *Alias) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
113
141
if ! ok {
114
142
return nil , errs .ObjectNotFound
115
143
}
144
+ // proxy || ftp,s3
145
+ if common .GetApiUrl (ctx ) == "" {
146
+ args .Redirect = false
147
+ }
116
148
for _ , dst := range dsts {
117
149
reqPath := stdpath .Join (dst , sub )
118
- link , file , err := d .link (ctx , reqPath , args )
150
+ link , fi , err := d .link (ctx , reqPath , args )
119
151
if err != nil {
120
152
continue
121
153
}
122
- var resultLink * model.Link
123
- if link != nil {
124
- resultLink = & model.Link {
125
- URL : link .URL ,
126
- Header : link .Header ,
127
- RangeReader : link .RangeReader ,
128
- SyncClosers : utils .NewSyncClosers (link ),
129
- ContentLength : link .ContentLength ,
130
- }
131
- if link .MFile != nil {
132
- resultLink .RangeReader = & model.FileRangeReader {
133
- RangeReaderIF : stream .GetRangeReaderFromMFile (file .GetSize (), link .MFile ),
134
- }
135
- }
136
-
137
- } else {
138
- resultLink = & model.Link {
154
+ if link == nil {
155
+ // 重定向且需要通过代理
156
+ return & model.Link {
139
157
URL : fmt .Sprintf ("%s/p%s?sign=%s" ,
140
158
common .GetApiUrl (ctx ),
141
159
utils .EncodePath (reqPath , true ),
142
160
sign .Sign (reqPath )),
143
- }
161
+ }, nil
162
+ }
163
+ if args .Redirect {
164
+ return link , nil
165
+ }
144
166
167
+ resultLink := & model.Link {
168
+ URL : link .URL ,
169
+ Header : link .Header ,
170
+ RangeReader : link .RangeReader ,
171
+ MFile : link .MFile ,
172
+ Concurrency : link .Concurrency ,
173
+ PartSize : link .PartSize ,
174
+ ContentLength : link .ContentLength ,
175
+ SyncClosers : utils .NewSyncClosers (link ),
145
176
}
146
- if ! args .Redirect {
147
- if d .DownloadConcurrency > 0 {
148
- resultLink .Concurrency = d .DownloadConcurrency
149
- }
150
- if d .DownloadPartSize > 0 {
151
- resultLink .PartSize = d .DownloadPartSize * utils .KB
152
- }
177
+ if resultLink .ContentLength == 0 {
178
+ resultLink .ContentLength = fi .GetSize ()
179
+ }
180
+ if resultLink .MFile != nil {
181
+ return resultLink , nil
182
+ }
183
+ if d .DownloadConcurrency > 0 {
184
+ resultLink .Concurrency = d .DownloadConcurrency
185
+ }
186
+ if d .DownloadPartSize > 0 {
187
+ resultLink .PartSize = d .DownloadPartSize * utils .KB
153
188
}
154
189
return resultLink , nil
155
190
}
0 commit comments