| 730 | } |
| 731 | |
| 732 | func (n *mutFile) newHandle(body io.Reader) (fs.Handle, error) { |
| 733 | tmp, err := os.CreateTemp("", "camli-") |
| 734 | if err == nil && body != nil { |
| 735 | _, err = io.Copy(tmp, body) |
| 736 | } |
| 737 | if err != nil { |
| 738 | Logger.Printf("mutFile.newHandle: %v", err) |
| 739 | if tmp != nil { |
| 740 | tmp.Close() |
| 741 | os.Remove(tmp.Name()) |
| 742 | } |
| 743 | return nil, fuse.EIO |
| 744 | } |
| 745 | return &mutFileHandle{f: n, tmp: tmp}, nil |
| 746 | } |
| 747 | |
| 748 | // mutFileHandle represents an open mutable file. |
| 749 | // It stores the file contents in a temporary file, and |