From 6630541399afd64ecce76b0197f0562ccf7f4da7 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 8 Apr 2020 12:50:59 -0700 Subject: [PATCH] ensure correct file size when opening existing files --- weed/filesys/filehandle.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 83a93c062..18544a7f1 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -33,12 +33,16 @@ type FileHandle struct { } func newFileHandle(file *File, uid, gid uint32) *FileHandle { - return &FileHandle{ + fh := &FileHandle{ f: file, dirtyPages: newDirtyPages(file), Uid: uid, Gid: gid, } + if fh.f.entry != nil { + fh.f.entry.Attributes.FileSize = filer2.TotalSize(fh.f.entry.Chunks) + } + return fh } var _ = fs.Handle(&FileHandle{})