|
5 | 5 | stderrors "errors"
|
6 | 6 | stdpath "path"
|
7 | 7 | "slices"
|
8 |
| - "strings" |
9 | 8 | "time"
|
10 | 9 |
|
11 | 10 | "github.com/OpenListTeam/OpenList/v4/internal/driver"
|
@@ -258,32 +257,11 @@ func Link(ctx context.Context, storage driver.Driver, path string, args model.Li
|
258 | 257 | if storage.Config().CheckStatus && storage.GetStorage().Status != WORK {
|
259 | 258 | return nil, nil, errors.Errorf("storage not init: %s", storage.GetStorage().Status)
|
260 | 259 | }
|
261 |
| - var ( |
262 |
| - file model.Obj |
263 |
| - err error |
264 |
| - ) |
265 |
| - // use cache directly |
266 |
| - dir, name := stdpath.Split(stdpath.Join(storage.GetStorage().MountPath, path)) |
267 |
| - if cacheFiles, ok := listCache.Get(strings.TrimSuffix(dir, "/")); ok { |
268 |
| - for _, f := range cacheFiles { |
269 |
| - if f.GetName() == name { |
270 |
| - file = model.UnwrapObj(f) |
271 |
| - break |
272 |
| - } |
273 |
| - } |
274 |
| - } else { |
275 |
| - if g, ok := storage.(driver.GetObjInfo); ok { |
276 |
| - file, err = g.GetObjInfo(ctx, path) |
277 |
| - } else { |
278 |
| - file, err = GetUnwrap(ctx, storage, path) |
279 |
| - } |
280 |
| - } |
281 |
| - if file == nil { |
282 |
| - if err != nil { |
283 |
| - return nil, nil, errors.WithMessage(err, "failed to get file") |
284 |
| - } |
285 |
| - return nil, nil, errors.WithStack(errs.ObjectNotFound) |
| 260 | + file, err := GetUnwrap(ctx, storage, path) |
| 261 | + if err != nil { |
| 262 | + return nil, nil, errors.WithMessage(err, "failed to get file") |
286 | 263 | }
|
| 264 | + |
287 | 265 | if file.IsDir() {
|
288 | 266 | return nil, nil, errors.WithStack(errs.NotFile)
|
289 | 267 | }
|
|
0 commit comments