diff --git a/internal/pss/vfs_workers.go b/internal/pss/vfs_workers.go index ee8ab67..e8a9bbc 100644 --- a/internal/pss/vfs_workers.go +++ b/internal/pss/vfs_workers.go @@ -44,8 +44,11 @@ func (v *vfsReadFile) execute(ctx context.Context, p *pss, timeout time.Duration commandCtx, cancel := context.WithTimeout(ctx, timeout) defer cancel() - file, err := p.vfs.Root(vent.VMRead).OpenAt(commandCtx, v.filePath) + root := p.vfs.Root(vent.VMRead) + + file, err := root.OpenAt(commandCtx, v.filePath) if err != nil { + _ = root.CloseCtx(commandCtx) return err } p.logger.Debug("file opened successfully", "path", v.filePath) @@ -195,8 +198,11 @@ func (v *vfsAddFile) execute(ctx context.Context, p *pss, timeout time.Duration) commandCtx, cancel := context.WithTimeout(ctx, timeout) defer cancel() - dir, err := p.vfs.Root(vent.VMWrite).OpenAt(commandCtx, v.path) + root := p.vfs.Root(vent.VMWrite) + + dir, err := root.OpenAt(commandCtx, v.path) if err != nil { + _ = root.CloseCtx(commandCtx) p.logger.Error("failed to open dir", "path", v.path, "err", err) return err }