Merge branch 'master' into master
diff --git a/request.go b/request.go
index 342933d..c8af66f 100644
--- a/request.go
+++ b/request.go
@@ -80,13 +80,18 @@
return r.pkt_id
}
-// Returns current offset for file list, and sets next offset
-func (r *Request) lsNext(offset int64) (current int64) {
+// Returns current offset for file list
+func (r *Request) lsNext() int64 {
r.stateLock.RLock()
defer r.stateLock.RUnlock()
- current = r.state.lsoffset
+ return r.state.lsoffset
+}
+
+// Increases next offset
+func (r *Request) lsInc(offset int64) {
+ r.stateLock.RLock()
+ defer r.stateLock.RUnlock()
r.state.lsoffset = r.state.lsoffset + offset
- return current
}
// manage file read/write state
@@ -251,9 +256,10 @@
r.setFileState(lister)
}
- offset := r.lsNext(MaxFilelist)
+ offset := r.lsNext()
finfo := make([]os.FileInfo, MaxFilelist)
n, err := lister.ListAt(finfo, offset)
+ r.lsInc(int64(n))
// ignore EOF as we only return it when there are no results
finfo = finfo[:n] // avoid need for nil tests below