| 1 | package toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ |
| 2 | |
| 3 | import "ioscip-go gomod github.com/golang/go/src go1.25.0 io/" |
| 4 | |
| 5 | // closeFn is the type of func Close() in the io.Closer interface. |
| 6 | type closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/closeFn# func() error |
| 7 | |
| 8 | // syncFn is the type of func Sync() in the *os.File implementation. |
| 9 | type syncFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/syncFn# func() error |
| 10 | |
| 11 | // SyncWriter provides a wrapper around an io.Writer that synchronizes all |
| 12 | // write after they occur, if the underlying writer supports synchronization. |
| 13 | type SyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter# struct { |
| 14 | wscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#w. ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Writerscip-go gomod github.com/golang/go/src go1.25.0 io/Writer# |
| 15 | |
| 16 | closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#closeFn. closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/closeFn# |
| 17 | syncFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#syncFn. syncFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/syncFn# |
| 18 | } |
| 19 | |
| 20 | // NewSyncWriter returns a new instance of the *SyncWriter that sends all writes |
| 21 | // to the given io.Writer. |
| 22 | func NewSyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewSyncWriter().(w ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Writerscip-go gomod github.com/golang/go/src go1.25.0 io/Writer#) *SyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter# { |
| 23 | sw := &SyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#{ |
| 24 | wscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#w.: w, |
| 25 | } |
| 26 | |
| 27 | if sync, ok := w.(interface { |
| 28 | Sync() error |
| 29 | }); ok { |
| 30 | sw.syncFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#syncFn. = sync.Sync |
| 31 | } else { |
| 32 | sw.syncFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#syncFn. = func() error { return nil } |
| 33 | } |
| 34 | |
| 35 | if close, ok := w.(ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Closerscip-go gomod github.com/golang/go/src go1.25.0 io/Closer#); ok { |
| 36 | sw.closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#closeFn. = close.Closescip-go gomod github.com/golang/go/src go1.25.0 io/Closer#Close(). |
| 37 | } else { |
| 38 | sw.closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#closeFn. = func() error { return nil } |
| 39 | } |
| 40 | |
| 41 | return sw |
| 42 | } |
| 43 | |
| 44 | // Write will write to the file and perform a Sync() if writing succeeds. |
| 45 | func (w *SyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#) Writescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#Write().(b []byte) error { |
| 46 | if _, err := w.wscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#w..Writescip-go gomod github.com/golang/go/src go1.25.0 io/Writer#Write().(b); err != nil { |
| 47 | return err |
| 48 | } |
| 49 | return w.syncFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#syncFn.() |
| 50 | } |
| 51 | |
| 52 | // Close will call Close() on the underlying file |
| 53 | func (w *SyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#) Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#Close().() error { |
| 54 | return w.closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#closeFn.() |
| 55 | } |