aboutsummaryrefslogtreecommitdiff
path: root/weed/storage/needle_map.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/storage/needle_map.go')
-rw-r--r--weed/storage/needle_map.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/weed/storage/needle_map.go b/weed/storage/needle_map.go
index 5b41286ea..d35391f66 100644
--- a/weed/storage/needle_map.go
+++ b/weed/storage/needle_map.go
@@ -1,7 +1,6 @@
package storage
import (
- "fmt"
"io"
"os"
"sync"
@@ -41,6 +40,7 @@ type baseNeedleMapper struct {
indexFile *os.File
indexFileAccessLock sync.Mutex
+ indexFileOffset int64
}
func (nm *baseNeedleMapper) IndexFileSize() uint64 {
@@ -56,11 +56,10 @@ func (nm *baseNeedleMapper) appendToIndexFile(key NeedleId, offset Offset, size
nm.indexFileAccessLock.Lock()
defer nm.indexFileAccessLock.Unlock()
- if _, err := nm.indexFile.Seek(0, 2); err != nil {
- return fmt.Errorf("cannot seek end of indexfile %s: %v",
- nm.indexFile.Name(), err)
+ written, err := nm.indexFile.WriteAt(bytes, nm.indexFileOffset)
+ if err == nil {
+ nm.indexFileOffset += int64(written)
}
- _, err := nm.indexFile.Write(bytes)
return err
}