-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve AtomicFileWriter's support for Win and Mac
Add ExplicitCommit option to provide calling code the ability to preserve original files when an application error occurs, not just an error that occurs during writing. Change Close() impl to safely handle redundant calls (for defer usage safety) Signed-off-by: Jason T. Greene <[email protected]>
- Loading branch information
Showing
5 changed files
with
179 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//go:build !linux | ||
// +build !linux | ||
|
||
package ioutils | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func dataOrFullSync(f *os.File) error { | ||
return f.Sync() | ||
} | ||
|
||
func (w *atomicFileWriter) postDataWrittenSync() error { | ||
// many platforms (Mac, Windows) require a full sync to reliably flush to media | ||
return nil | ||
} | ||
|
||
func (w *atomicFileWriter) preRenameSync() error { | ||
if w.noSync { | ||
return nil | ||
} | ||
|
||
// fsync() on Non-linux Unix, FlushFileBuffers (Windows), F_FULLFSYNC (Mac) | ||
return w.f.Sync() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.