func GetWriterStore()

in v3/internal/helper.go [17:40]


func GetWriterStore(path string, useTempFile bool) (*writerStore, error) {
	if !useTempFile {
		return &writerStore{
			ReadWriteSeeker: &bytesReadWriteSeeker{},
			Cleanup:         func() {},
		}, nil
	}
	// Create temp file to be used later for calculating the SHA256 header
	f, err := os.CreateTemp(path, "")
	if err != nil {
		return nil, err
	}

	ws := &writerStore{
		ReadWriteSeeker: f,
		Cleanup: func() {
			// Close the temp file and Cleanup
			f.Close()
			os.Remove(f.Name())
		},
	}

	return ws, nil
}