@@ -78,10 +78,18 @@ func (d *Alias) Get(ctx context.Context, path string) (model.Obj, error) {
7878 return nil , errs .ObjectNotFound
7979 }
8080 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
8484 }
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
8593 }
8694 return nil , errs .ObjectNotFound
8795}
@@ -99,7 +107,27 @@ func (d *Alias) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
99107 var objs []model.Obj
100108 fsArgs := & fs.ListArgs {NoLog : true , Refresh : args .Refresh }
101109 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+ }
103131 if err == nil {
104132 objs = append (objs , tmp ... )
105133 }
@@ -113,43 +141,50 @@ func (d *Alias) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
113141 if ! ok {
114142 return nil , errs .ObjectNotFound
115143 }
144+ // proxy || ftp,s3
145+ if common .GetApiUrl (ctx ) == "" {
146+ args .Redirect = false
147+ }
116148 for _ , dst := range dsts {
117149 reqPath := stdpath .Join (dst , sub )
118- link , file , err := d .link (ctx , reqPath , args )
150+ link , fi , err := d .link (ctx , reqPath , args )
119151 if err != nil {
120152 continue
121153 }
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 {
139157 URL : fmt .Sprintf ("%s/p%s?sign=%s" ,
140158 common .GetApiUrl (ctx ),
141159 utils .EncodePath (reqPath , true ),
142160 sign .Sign (reqPath )),
143- }
161+ }, nil
162+ }
163+ if args .Redirect {
164+ return link , nil
165+ }
144166
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 ),
145176 }
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
153188 }
154189 return resultLink , nil
155190 }
0 commit comments