Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rename file failed #657

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions internal/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -978,20 +978,24 @@ func (parent *Inode) isEmptyDir(fs *Goofys, name string) (isDir bool, err error)
Prefix: &key,
})
if err != nil {
s3Log.Debugf("ListBlobs 1 in isEmptyDir, resp is %v, err is %v", resp, err)
return false, mapAwsError(err)
}

if len(resp.Prefixes) > 0 || len(resp.Items) > 1 {
err = fuse.ENOTEMPTY
isDir = true
s3Log.Debugf("ListBlobs 2 in isEmptyDir, resp is %v, err is %v", resp, err)
return
}

if len(resp.Items) == 1 {
isDir = true
s3Log.Debugf("ListBlobs 3 in isEmptyDir")

if *resp.Items[0].Key != key {
err = fuse.ENOTEMPTY
s3Log.Debugf("ListBlobs 4 in isEmptyDir")
}
}

Expand Down Expand Up @@ -1072,8 +1076,11 @@ func (parent *Inode) Rename(from string, newParent *Inode, to string) (err error

toFullName := appendChildName(toPath, to)

toIsDir, err = parent.isEmptyDir(fs, to)
if err != nil {
toIsDir, err = newParent.isEmptyDir(fs, to)
s3Log.Debugf("toFullName is %v, toPath is %v, to is %v", toFullName, toPath, to)
s3Log.Debugf("outter toIsDir is %v, err is %v", toIsDir, err)
if err != nil && err != fuse.ENOENT {
s3Log.Debugf("inner toIsDir is %v, err is %v", toIsDir, err)
return
}

Expand Down Expand Up @@ -1364,6 +1371,7 @@ func (parent *Inode) LookUpInodeMaybeDir(name string, fullName string) (inode *I
inode.fillXattrFromHead(&resp)
return
case err = <-errObjectChan:
s3Log.Debugf("chan error is errObjectChan")
checking--
checkErr[0] = err
s3Log.Debugf("HEAD %v = %v", fullName, err)
Expand Down Expand Up @@ -1394,10 +1402,12 @@ func (parent *Inode) LookUpInodeMaybeDir(name string, fullName string) (inode *I
checking--
}
case err = <-errDirChan:
s3Log.Debugf("chan error is errDirChan")
checking--
checkErr[2] = err
s3Log.Debugf("LIST %v/ = %v", fullName, err)
case err = <-errDirBlobChan:
s3Log.Debugf("chan error is errDirBlobChan")
checking--
checkErr[1] = err
s3Log.Debugf("HEAD %v/ = %v", fullName, err)
Expand All @@ -1407,6 +1417,7 @@ func (parent *Inode) LookUpInodeMaybeDir(name string, fullName string) (inode *I
return
}

s3Log.Debugf("checking is %v", checking)
switch checking {
case 2:
if parent.fs.flags.Cheap {
Expand All @@ -1425,7 +1436,8 @@ func (parent *Inode) LookUpInodeMaybeDir(name string, fullName string) (inode *I
doneCase:
fallthrough
case 0:
for _, e := range checkErr {
for x, e := range checkErr {
s3Log.Debugf("checkErr x = %v e = %v", x, e)
if e != fuse.ENOENT {
err = e
return
Expand Down
5 changes: 5 additions & 0 deletions internal/goofys.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ func (fs *Goofys) LookUpInode(
var ok bool
defer func() { fuseLog.Debugf("<-- LookUpInode %v %v %v", op.Parent, op.Name, err) }()

fuseLog.Debugf("<-- do LookUpInode %v %v %v", op.Parent, op.Name)

fs.mu.RLock()
parent := fs.getInodeOrDie(op.Parent)
fs.mu.RUnlock()
Expand Down Expand Up @@ -634,6 +636,7 @@ func (fs *Goofys) LookUpInode(
var newInode *Inode

newInode, err = parent.LookUp(op.Name)
fuseLog.Debugf("<-- parent.LookUp return is %v %v", newInode, err)
if err == fuse.ENOENT && inode != nil && inode.isDir() {
// we may not be able to look up an implicit
// dir if all the children are removed, so we
Expand Down Expand Up @@ -1159,6 +1162,8 @@ func (fs *Goofys) Rename(
defer newParent.mu.Unlock()
}

s3Log.Debugf("op is %v, op.OldParent is %v, op.NewParent is %v, parent is %v, newParent is %v", op, op.OldParent, op.NewParent, parent, newParent)
s3Log.Debugf("op.OldName is %v, op.NewName is %v", op.OldName, op.NewName)
err = parent.Rename(op.OldName, newParent, op.NewName)
if err != nil {
if err == fuse.ENOENT {
Expand Down
4 changes: 2 additions & 2 deletions internal/handles.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func (inode *Inode) SetXattr(name string, value []byte, flags uint32) error {
inode.mu.Lock()
defer inode.mu.Unlock()

meta, name, err := inode.getXattrMap(name, true)
meta, name, err := inode.getXattrMap(name, false)
if err != nil {
return err
}
Expand Down Expand Up @@ -456,7 +456,7 @@ func (inode *Inode) RemoveXattr(name string) error {
inode.mu.Lock()
defer inode.mu.Unlock()

meta, name, err := inode.getXattrMap(name, true)
meta, name, err := inode.getXattrMap(name, false)
if err != nil {
return err
}
Expand Down