Skip to content

Commit

Permalink
Remove temp files after reading from EOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Oct 21, 2020
1 parent 1240df4 commit 970c59c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/eosclient/eosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions pkg/eosclientgrpc/eosclientgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 970c59c

Please sign in to comment.