@@ -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,42 +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 )
118150 link , fi , err := d .link (ctx , reqPath , args )
119151 if err != nil {
120152 continue
121153 }
122154 if link == nil {
123- // 重定向
155+ // 重定向且需要通过代理
124156 return & model.Link {
125157 URL : fmt .Sprintf ("%s/p%s?sign=%s" ,
126158 common .GetApiUrl (ctx ),
127159 utils .EncodePath (reqPath , true ),
128160 sign .Sign (reqPath )),
129161 }, nil
130162 }
131-
132- if args .Redirect || link .MFile == nil && d .DownloadConcurrency <= 0 && d .DownloadPartSize <= 0 {
133- // 不修改link的字段,可直接返回
163+ if args .Redirect {
134164 return link , nil
135165 }
136166
137167 resultLink := & model.Link {
138168 URL : link .URL ,
139169 Header : link .Header ,
140170 RangeReader : link .RangeReader ,
141- Concurrency : d .DownloadConcurrency ,
142- PartSize : d .DownloadPartSize * utils .KB ,
171+ MFile : link .MFile ,
172+ Concurrency : link .Concurrency ,
173+ PartSize : link .PartSize ,
143174 ContentLength : link .ContentLength ,
144175 SyncClosers : utils .NewSyncClosers (link ),
145176 }
146- if link .MFile != nil {
147- resultLink .RangeReader = & model.FileRangeReader {
148- // MFile并发响应 线程不安全
149- // 包装成RangeReader 使用io.ReaderAt接口实现线程安全
150- RangeReaderIF : stream .GetRangeReaderFromMFile (fi .GetSize (), link .MFile ),
151- }
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
152188 }
153189 return resultLink , nil
154190 }
0 commit comments