aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/filehandle.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-01-05 15:16:39 -0800
committerChris Lu <chris.lu@gmail.com>2019-01-05 15:16:39 -0800
commitd9f9aca453018c8decc1ab4882f0a6dd62bc2288 (patch)
treecc4f155c243dd2dacebbdf7217f18aa50cadbdd9 /weed/filesys/filehandle.go
parent251b596bc535b2e6361c698c44960cdb0fbe017f (diff)
downloadseaweedfs-d9f9aca453018c8decc1ab4882f0a6dd62bc2288.tar.xz
seaweedfs-d9f9aca453018c8decc1ab4882f0a6dd62bc2288.zip
refactoring
Diffstat (limited to 'weed/filesys/filehandle.go')
-rw-r--r--weed/filesys/filehandle.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index 8909da52a..23741a052 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -157,10 +157,9 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f
fh.dirtyMetadata = true
}
- for _, chunk := range chunks {
- fh.f.entry.Chunks = append(fh.f.entry.Chunks, chunk)
- fh.f.entryViewCache = nil
- glog.V(4).Infof("uploaded %s/%s to %s [%d,%d)", fh.f.dir.Path, fh.f.Name, chunk.FileId, chunk.Offset, chunk.Offset+int64(chunk.Size))
+ fh.f.addChunks(chunks)
+
+ if len(chunks) > 0 {
fh.dirtyMetadata = true
}
@@ -190,10 +189,8 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error {
glog.Errorf("flush %s/%s: %v", fh.f.dir.Path, fh.f.Name, err)
return fmt.Errorf("flush %s/%s: %v", fh.f.dir.Path, fh.f.Name, err)
}
- if chunk != nil {
- fh.f.entry.Chunks = append(fh.f.entry.Chunks, chunk)
- fh.f.entryViewCache = nil
- }
+
+ fh.f.addChunk(chunk)
if !fh.dirtyMetadata {
return nil
@@ -222,7 +219,7 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error {
chunks, garbages := filer2.CompactFileChunks(fh.f.entry.Chunks)
fh.f.entry.Chunks = chunks
- fh.f.entryViewCache = nil
+ // fh.f.entryViewCache = nil
fh.f.wfs.asyncDeleteFileChunks(garbages)
if _, err := client.CreateEntry(ctx, request); err != nil {