file.go | 9 +++++---- diff --git a/file.go b/file.go index e2720e5a4d0886e0e75c620ac7187a7c8a037479..35fe9239aaaba3a0191d220f46d0e84fe79e1aa5 100644 --- a/file.go +++ b/file.go @@ -44,13 +44,14 @@ } // Number of bytes of the entire file we have completed. This is the sum of // completed pieces, and dirtied chunks of incomplete pieces. -func (f *File) BytesCompleted() int64 { +func (f *File) BytesCompleted() (n int64) { f.t.cl.rLock() - defer f.t.cl.rUnlock() - return f.bytesCompleted() + n = f.bytesCompletedLocked() + f.t.cl.rUnlock() + return } -func (f *File) bytesCompleted() int64 { +func (f *File) bytesCompletedLocked() int64 { return f.length - f.bytesLeft() }