Browse Source

stop renaming worm files (#6154)

* stop renaming worm file

Signed-off-by: lou <alex1988@outlook.com>

* update after review

Signed-off-by: lou <alex1988@outlook.com>

* Update weed/server/filer_server_handlers_write.go

---------

Signed-off-by: lou <alex1988@outlook.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
pull/5759/merge
Guang Jiong Lou 2 months ago
committed by GitHub
parent
commit
9369a88c5c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 14
      weed/mount/weedfs_rename.go
  2. 8
      weed/server/filer_server_handlers_write.go

14
weed/mount/weedfs_rename.go

@ -3,15 +3,16 @@ package mount
import ( import (
"context" "context"
"fmt" "fmt"
"io"
"strings"
"syscall"
"github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fs"
"github.com/hanwen/go-fuse/v2/fuse" "github.com/hanwen/go-fuse/v2/fuse"
"github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/filer"
"github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util" "github.com/seaweedfs/seaweedfs/weed/util"
"io"
"strings"
"syscall"
) )
/** Rename a file /** Rename a file
@ -160,6 +161,13 @@ func (wfs *WFS) Rename(cancel <-chan struct{}, in *fuse.RenameIn, oldName string
} }
newPath := newDir.Child(newName) newPath := newDir.Child(newName)
if wfs.FilerConf != nil {
rule := wfs.FilerConf.MatchStorageRule(string(oldPath))
if rule.Worm {
return fuse.EPERM
}
}
glog.V(4).Infof("dir Rename %s => %s", oldPath, newPath) glog.V(4).Infof("dir Rename %s => %s", oldPath, newPath)
// update remote filer // update remote filer

8
weed/server/filer_server_handlers_write.go

@ -160,6 +160,14 @@ func (fs *FilerServer) move(ctx context.Context, w http.ResponseWriter, r *http.
return return
} }
rule := fs.filer.FilerConf.MatchStorageRule(src)
if rule.Worm {
// you cannot move a worm file or directory
err = fmt.Errorf("cannot move write-once entry from '%s' to '%s': operation not permitted", src, dst)
writeJsonError(w, r, http.StatusForbidden, err)
return
}
oldDir, oldName := srcPath.DirAndName() oldDir, oldName := srcPath.DirAndName()
newDir, newName := dstPath.DirAndName() newDir, newName := dstPath.DirAndName()
newName = util.Nvl(newName, oldName) newName = util.Nvl(newName, oldName)

Loading…
Cancel
Save