(ctx context.Context, action, src, dst string, d *data, fileCache FileCache)
| 338 | } |
| 339 | |
| 340 | func patchAction(ctx context.Context, action, src, dst string, d *data, fileCache FileCache) error { |
| 341 | switch action { |
| 342 | case "copy": |
| 343 | if !d.user.Perm.Create { |
| 344 | return fberrors.ErrPermissionDenied |
| 345 | } |
| 346 | |
| 347 | return fileutils.Copy(d.user.Fs, src, dst, d.settings.FileMode, d.settings.DirMode) |
| 348 | case "rename": |
| 349 | if !d.user.Perm.Rename { |
| 350 | return fberrors.ErrPermissionDenied |
| 351 | } |
| 352 | src = path.Clean("/" + src) |
| 353 | dst = path.Clean("/" + dst) |
| 354 | |
| 355 | file, err := files.NewFileInfo(&files.FileOptions{ |
| 356 | Fs: d.user.Fs, |
| 357 | Path: src, |
| 358 | Modify: d.user.Perm.Modify, |
| 359 | Expand: false, |
| 360 | ReadHeader: false, |
| 361 | Checker: d, |
| 362 | }) |
| 363 | if err != nil { |
| 364 | return err |
| 365 | } |
| 366 | |
| 367 | // delete thumbnails |
| 368 | err = delThumbs(ctx, fileCache, file) |
| 369 | if err != nil { |
| 370 | return err |
| 371 | } |
| 372 | |
| 373 | return fileutils.MoveFile(d.user.Fs, src, dst, d.settings.FileMode, d.settings.DirMode) |
| 374 | default: |
| 375 | return fmt.Errorf("unsupported action %s: %w", action, fberrors.ErrInvalidRequestParams) |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | // RecursiveEntry is a single file/directory entry returned by the recursive listing endpoint. |
| 380 | type RecursiveEntry struct { |
no test coverage detected