Skip to content

Commit

Permalink
[CR] Clean up deleteOnClose and clarify Close implementation comment
Browse files Browse the repository at this point in the history
  • Loading branch information
arielshaqed committed Mar 24, 2021
1 parent 6bde004 commit 28a69ae
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions cmd/lakectl/cmd/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,9 @@ type deleteOnClose struct {
*os.File
}

func (d *deleteOnClose) Read(p []byte) (n int, err error) {
return d.File.Read(p)
}

func (d *deleteOnClose) Seek(offset int64, whence int) (int64, error) {
return d.File.Seek(offset, whence)
}

func (d *deleteOnClose) Close() error {
if err := os.Remove(d.Name()); err != nil {
d.File.Close() // Close failure is unimportant on read, but data definitely stays!
d.File.Close() // "Only" file descriptor leak if close fails (but data might stay).
return fmt.Errorf("delete on close: %w", err)
}
return d.File.Close()
Expand Down

0 comments on commit 28a69ae

Please sign in to comment.