Skip to content

Commit

Permalink
enhance: cancel context when emptyDir failed (#4389)
Browse files Browse the repository at this point in the history
Signed-off-by: jiefeng <[email protected]>
  • Loading branch information
jiefenghuang authored Jan 30, 2024
1 parent 5879e5b commit d46d208
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/meta/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,15 @@ func (m *baseMeta) emptyDir(ctx Context, inode Ino, skipCheckTrash bool, count *
wg.Add(1)
go func(child Ino, name string) {
defer wg.Done()
e := m.emptyEntry(ctx, inode, name, child, skipCheckTrash, count, concurrent)
if e != 0 && e != syscall.ENOENT {
status = e
st := m.emptyEntry(ctx, inode, name, child, skipCheckTrash, count, concurrent)
if st != 0 && st != syscall.ENOENT {
status = st
}
<-concurrent
}(e.Inode, string(e.Name))
default:
if st := m.emptyEntry(ctx, inode, string(e.Name), e.Inode, skipCheckTrash, count, concurrent); st != 0 && st != syscall.ENOENT {
ctx.Cancel()
return st
}
}
Expand All @@ -300,6 +301,7 @@ func (m *baseMeta) emptyDir(ctx Context, inode Ino, skipCheckTrash bool, count *
atomic.AddUint64(count, 1)
}
if st := m.Unlink(ctx, inode, string(e.Name), skipCheckTrash); st != 0 && st != syscall.ENOENT {
ctx.Cancel()
return st
}
}
Expand Down

0 comments on commit d46d208

Please sign in to comment.