You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
750 B

  1. package filesys
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  6. "github.com/seaweedfs/fuse"
  7. "github.com/seaweedfs/fuse/fs"
  8. )
  9. func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirectory fs.Node) error {
  10. newDir := newDirectory.(*Dir)
  11. return dir.wfs.WithFilerClient(ctx, func(client filer_pb.SeaweedFilerClient) error {
  12. request := &filer_pb.AtomicRenameEntryRequest{
  13. OldDirectory: dir.Path,
  14. OldName: req.OldName,
  15. NewDirectory: newDir.Path,
  16. NewName: req.NewName,
  17. }
  18. _, err := client.AtomicRenameEntry(ctx, request)
  19. if err != nil {
  20. return fmt.Errorf("renaming %s/%s => %s/%s: %v", dir.Path, req.OldName, newDir.Path, req.NewName, err)
  21. }
  22. return nil
  23. })
  24. }