diff --git a/changelog/unreleased/fix-more-fd-leaks.md b/changelog/unreleased/fix-more-fd-leaks.md new file mode 100644 index 0000000000..e0ad4e5180 --- /dev/null +++ b/changelog/unreleased/fix-more-fd-leaks.md @@ -0,0 +1,5 @@ +Bugfix: Fix fd leaks + +There were some left over open file descriptors on simple.go. + +https://github.com/cs3org/reva/pull/1338 \ No newline at end of file diff --git a/pkg/rhttp/datatx/manager/simple/simple.go b/pkg/rhttp/datatx/manager/simple/simple.go index a48fec6672..8793d1cfb4 100644 --- a/pkg/rhttp/datatx/manager/simple/simple.go +++ b/pkg/rhttp/datatx/manager/simple/simple.go @@ -89,6 +89,7 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) { } return } + defer rc.Close() _, err = io.Copy(w, rc) if err != nil { diff --git a/pkg/storage/fs/ocis/recycle.go b/pkg/storage/fs/ocis/recycle.go index 31022e5fd9..63cef3aa18 100644 --- a/pkg/storage/fs/ocis/recycle.go +++ b/pkg/storage/fs/ocis/recycle.go @@ -69,6 +69,7 @@ func (fs *ocisfs) ListRecycle(ctx context.Context) (items []*provider.RecycleIte } return nil, errors.Wrap(err, "tree: error listing "+trashRoot) } + defer f.Close() names, err := f.Readdirnames(0) if err != nil { diff --git a/pkg/storage/fs/ocis/tree.go b/pkg/storage/fs/ocis/tree.go index 5e16f9d3a3..165ccf9520 100644 --- a/pkg/storage/fs/ocis/tree.go +++ b/pkg/storage/fs/ocis/tree.go @@ -200,7 +200,6 @@ func (t *Tree) Move(ctx context.Context, oldNode *Node, newNode *Node) (err erro // ListFolder lists the content of a folder node func (t *Tree) ListFolder(ctx context.Context, node *Node) ([]*Node, error) { - dir := t.lu.toInternalPath(node.ID) f, err := os.Open(dir) if err != nil { @@ -209,6 +208,7 @@ func (t *Tree) ListFolder(ctx context.Context, node *Node) ([]*Node, error) { } return nil, errors.Wrap(err, "tree: error listing "+dir) } + defer f.Close() names, err := f.Readdirnames(0) if err != nil { diff --git a/pkg/storage/fs/ocis/upload.go b/pkg/storage/fs/ocis/upload.go index a41ea51cdd..e4d4072410 100644 --- a/pkg/storage/fs/ocis/upload.go +++ b/pkg/storage/fs/ocis/upload.go @@ -546,6 +546,7 @@ func (upload *fileUpload) ConcatUploads(ctx context.Context, uploads []tusd.Uplo if err != nil { return err } + defer src.Close() if _, err := io.Copy(file, src); err != nil { return err