Skip to content

Commit 6472d74

Browse files
committed
chunked: Refactor temporary file creation
Replace the direct call to unix.Open with the O_TMPFILE flag with the dedicated openTmpFile helper function. Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent afbdeda commit 6472d74

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pkg/chunked/storage_linux.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,11 @@ func (c *chunkedDiffer) convertTarToZstdChunked(destDirectory string, payload *o
163163

164164
defer diff.Close()
165165

166-
fd, err := unix.Open(destDirectory, unix.O_TMPFILE|unix.O_RDWR|unix.O_CLOEXEC, 0o600)
166+
f, err := openTmpFile(destDirectory)
167167
if err != nil {
168-
return 0, nil, "", nil, &fs.PathError{Op: "open", Path: destDirectory, Err: err}
168+
return 0, nil, "", nil, err
169169
}
170170

171-
f := os.NewFile(uintptr(fd), destDirectory)
172-
173171
newAnnotations := make(map[string]string)
174172
level := 1
175173
chunked, err := compressor.ZstdCompressor(f, newAnnotations, &level)

0 commit comments

Comments
 (0)