mirror of
https://github.com/rclone/rclone.git
synced 2026-01-06 18:43:50 +00:00
fuse: Add bandwidth accounting and buffering
This fixes rclone mount ignoring bwlimit and increases buffering which should speed up transfers greatly. Fixes #796 Fixes #690
This commit is contained in:
@@ -27,10 +27,11 @@ func newReadFileHandle(o fs.Object) (*ReadFileHandle, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ReadFileHandle{
|
||||
r: r,
|
||||
fh := &ReadFileHandle{
|
||||
o: o,
|
||||
}, nil
|
||||
r: fs.NewAccount(r, o), // account and buffer the transfer
|
||||
}
|
||||
return fh, nil
|
||||
}
|
||||
|
||||
// Check interface satisfied
|
||||
@@ -63,7 +64,7 @@ func (fh *ReadFileHandle) seek(offset int64) error {
|
||||
if err != nil {
|
||||
fs.Debug(fh.o, "ReadFileHandle.Read seek close old failed: %v", err)
|
||||
}
|
||||
fh.r = r
|
||||
fh.r = fs.NewAccount(r, fh.o) // account and buffer the transfer
|
||||
}
|
||||
fh.offset = offset
|
||||
return nil
|
||||
|
||||
@@ -38,8 +38,9 @@ func newWriteFileHandle(d *Dir, f *File, src fs.ObjectInfo) (*WriteFileHandle, e
|
||||
file: f,
|
||||
}
|
||||
fh.pipeReader, fh.pipeWriter = io.Pipe()
|
||||
r := fs.NewAccountSizeName(fh.pipeReader, 0, src.Remote()) // account and buffer the transfer
|
||||
go func() {
|
||||
o, err := d.f.Put(fh.pipeReader, src)
|
||||
o, err := d.f.Put(r, src)
|
||||
fh.o = o
|
||||
fh.result <- err
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user