forked from TrueCloudLab/rclone
fs: introduces aliases for OpenWriterAtFn and OpenChunkWriterFn
This commit is contained in:
parent
0dea83a4aa
commit
b4e3332e02
2 changed files with 8 additions and 1 deletions
|
@ -636,6 +636,9 @@ type OpenWriterAter interface {
|
||||||
OpenWriterAt(ctx context.Context, remote string, size int64) (WriterAtCloser, error)
|
OpenWriterAt(ctx context.Context, remote string, size int64) (WriterAtCloser, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OpenWriterAtFn describes the OpenWriterAt function pointer
|
||||||
|
type OpenWriterAtFn func(ctx context.Context, remote string, size int64) (WriterAtCloser, error)
|
||||||
|
|
||||||
type OpenChunkWriter interface {
|
type OpenChunkWriter interface {
|
||||||
// OpenChunkWriter returns the chunk size and a ChunkWriter
|
// OpenChunkWriter returns the chunk size and a ChunkWriter
|
||||||
//
|
//
|
||||||
|
@ -644,6 +647,9 @@ type OpenChunkWriter interface {
|
||||||
OpenChunkWriter(ctx context.Context, remote string, src ObjectInfo, options ...OpenOption) (chunkSize int64, writer ChunkWriter, err error)
|
OpenChunkWriter(ctx context.Context, remote string, src ObjectInfo, options ...OpenOption) (chunkSize int64, writer ChunkWriter, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OpenChunkWriterFn describes the OpenChunkWriter function pointer
|
||||||
|
type OpenChunkWriterFn func(ctx context.Context, remote string, src ObjectInfo, options ...OpenOption) (chunkSize int64, writer ChunkWriter, err error)
|
||||||
|
|
||||||
type ChunkWriter interface {
|
type ChunkWriter interface {
|
||||||
// WriteChunk will write chunk number with reader bytes, where chunk number >= 0
|
// WriteChunk will write chunk number with reader bytes, where chunk number >= 0
|
||||||
WriteChunk(chunkNumber int, reader io.ReadSeeker) (bytesWritten int64, err error)
|
WriteChunk(chunkNumber int, reader io.ReadSeeker) (bytesWritten int64, err error)
|
||||||
|
|
|
@ -277,7 +277,8 @@ func (w writerAtChunkWriter) Abort() error {
|
||||||
return obj.Remove(w.ctx)
|
return obj.Remove(w.ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func openChunkWriterFromOpenWriterAt(openWriterAt func(ctx context.Context, remote string, size int64) (fs.WriterAtCloser, error), chunkSize int64, writeBufferSize int64, f fs.Fs) func(ctx context.Context, remote string, src fs.ObjectInfo, options ...fs.OpenOption) (chunkSizeResult int64, writer fs.ChunkWriter, err error) {
|
// openChunkWriterFromOpenWriterAt adapts an OpenWriterAtFn into an OpenChunkWriterFn using chunkSize and writeBufferSize
|
||||||
|
func openChunkWriterFromOpenWriterAt(openWriterAt fs.OpenWriterAtFn, chunkSize int64, writeBufferSize int64, f fs.Fs) fs.OpenChunkWriterFn {
|
||||||
return func(ctx context.Context, remote string, src fs.ObjectInfo, options ...fs.OpenOption) (chunkSizeResult int64, writer fs.ChunkWriter, err error) {
|
return func(ctx context.Context, remote string, src fs.ObjectInfo, options ...fs.OpenOption) (chunkSizeResult int64, writer fs.ChunkWriter, err error) {
|
||||||
writerAt, err := openWriterAt(ctx, remote, src.Size())
|
writerAt, err := openWriterAt(ctx, remote, src.Size())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue