diff --git a/pkg/eosclient/eosclient.go b/pkg/eosclient/eosclient.go index d7fbb9520e9..37977466d00 100644 --- a/pkg/eosclient/eosclient.go +++ b/pkg/eosclient/eosclient.go @@ -550,9 +550,10 @@ func (c *Client) List(ctx context.Context, uid, gid, path string) ([]*FileInfo, // Read reads a file from the mgm func (c *Client) Read(ctx context.Context, uid, gid, path string) (io.ReadCloser, error) { - uuid := uuid.Must(uuid.NewV4()) - rand := "eosread-" + uuid.String() + rand := "eosread-" + uuid.Must(uuid.NewV4()).String() localTarget := fmt.Sprintf("%s/%s", c.opt.CacheDirectory, rand) + defer os.RemoveAll(localTarget) + xrdPath := fmt.Sprintf("%s//%s", c.opt.URL, path) cmd := exec.CommandContext(ctx, c.opt.XrdcopyBinary, "--nopbar", "--silent", "-f", xrdPath, localTarget, fmt.Sprintf("-OSeos.ruid=%s&eos.rgid=%s", uid, gid)) _, _, err := c.execute(ctx, cmd) diff --git a/pkg/eosclientgrpc/eosclientgrpc.go b/pkg/eosclientgrpc/eosclientgrpc.go index def76bac9a5..0df6b8a9490 100644 --- a/pkg/eosclientgrpc/eosclientgrpc.go +++ b/pkg/eosclientgrpc/eosclientgrpc.go @@ -997,9 +997,10 @@ func (c *Client) Read(ctx context.Context, username, path string) (io.ReadCloser if err != nil { return nil, err } - uuid := uuid.Must(uuid.NewV4()) - rand := "eosread-" + uuid.String() + rand := "eosread-" + uuid.Must(uuid.NewV4()).String() localTarget := fmt.Sprintf("%s/%s", c.opt.CacheDirectory, rand) + defer os.RemoveAll(localTarget) + xrdPath := fmt.Sprintf("%s//%s", c.opt.URL, path) cmd := exec.CommandContext(ctx, c.opt.XrdcopyBinary, "--nopbar", "--silent", "-f", xrdPath, localTarget, fmt.Sprintf("-OSeos.ruid=%s&eos.rgid=%s", unixUser.Uid, unixUser.Gid)) _, _, err = c.execute(ctx, cmd)