mirror of
https://github.com/containers/podman.git
synced 2025-12-11 01:11:30 +08:00
Bump github.com/containers/storage from 1.19.1 to 1.19.2
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.19.1 to 1.19.2. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/master/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.19.1...v1.19.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Valentin Rothberg <rothberg@redhat.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
committed by
Daniel J Walsh
parent
150679d7b1
commit
1f0cc866d4
48
vendor/github.com/containers/storage/pkg/ioutils/fswriters.go
generated
vendored
48
vendor/github.com/containers/storage/pkg/ioutils/fswriters.go
generated
vendored
@@ -7,26 +7,53 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// NewAtomicFileWriter returns WriteCloser so that writing to it writes to a
|
||||
// AtomicFileWriterOptions specifies options for creating the atomic file writer.
|
||||
type AtomicFileWriterOptions struct {
|
||||
// NoSync specifies whether the sync call must be skipped for the file.
|
||||
// If NoSync is not specified, the file is synced to the
|
||||
// storage after it has been written and before it is moved to
|
||||
// the specified path.
|
||||
NoSync bool
|
||||
}
|
||||
|
||||
var defaultWriterOptions AtomicFileWriterOptions = AtomicFileWriterOptions{}
|
||||
|
||||
// SetDefaultOptions overrides the default options used when creating an
|
||||
// atomic file writer.
|
||||
func SetDefaultOptions(opts AtomicFileWriterOptions) {
|
||||
defaultWriterOptions = opts
|
||||
}
|
||||
|
||||
// NewAtomicFileWriterWithOpts returns WriteCloser so that writing to it writes to a
|
||||
// temporary file and closing it atomically changes the temporary file to
|
||||
// destination path. Writing and closing concurrently is not allowed.
|
||||
func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, error) {
|
||||
func NewAtomicFileWriterWithOpts(filename string, perm os.FileMode, opts *AtomicFileWriterOptions) (io.WriteCloser, error) {
|
||||
f, err := ioutil.TempFile(filepath.Dir(filename), ".tmp-"+filepath.Base(filename))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if opts == nil {
|
||||
opts = &defaultWriterOptions
|
||||
}
|
||||
abspath, err := filepath.Abs(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &atomicFileWriter{
|
||||
f: f,
|
||||
fn: abspath,
|
||||
perm: perm,
|
||||
f: f,
|
||||
fn: abspath,
|
||||
perm: perm,
|
||||
noSync: opts.NoSync,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewAtomicFileWriter returns WriteCloser so that writing to it writes to a
|
||||
// temporary file and closing it atomically changes the temporary file to
|
||||
// destination path. Writing and closing concurrently is not allowed.
|
||||
func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, error) {
|
||||
return NewAtomicFileWriterWithOpts(filename, perm, nil)
|
||||
}
|
||||
|
||||
// AtomicWriteFile atomically writes data to a file named by filename.
|
||||
func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error {
|
||||
f, err := NewAtomicFileWriter(filename, perm)
|
||||
@@ -49,6 +76,7 @@ type atomicFileWriter struct {
|
||||
fn string
|
||||
writeErr error
|
||||
perm os.FileMode
|
||||
noSync bool
|
||||
}
|
||||
|
||||
func (w *atomicFileWriter) Write(dt []byte) (int, error) {
|
||||
@@ -65,9 +93,11 @@ func (w *atomicFileWriter) Close() (retErr error) {
|
||||
os.Remove(w.f.Name())
|
||||
}
|
||||
}()
|
||||
if err := fdatasync(w.f); err != nil {
|
||||
w.f.Close()
|
||||
return err
|
||||
if !w.noSync {
|
||||
if err := fdatasync(w.f); err != nil {
|
||||
w.f.Close()
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := w.f.Close(); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user