aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/filehandle.go
diff options
context:
space:
mode:
authorKonstantin Lebedev <lebedev_k@tochka.com>2021-03-16 15:29:49 +0500
committerKonstantin Lebedev <lebedev_k@tochka.com>2021-03-16 15:29:49 +0500
commiteb54993a4eacffde48007bb3bcc46b664d38c403 (patch)
tree1ef3f4cd86f9772631496a193bdeb62e25e780de /weed/filesys/filehandle.go
parent06da02739d4a97dd8288f7fa05de7cd369e97d78 (diff)
parent9672f9e1b2ed399470e6ec877a667417c8b26870 (diff)
downloadseaweedfs-eb54993a4eacffde48007bb3bcc46b664d38c403.tar.xz
seaweedfs-eb54993a4eacffde48007bb3bcc46b664d38c403.zip
Merge branch 'upstreamMaster' into check_chunkviews_mr
# Conflicts: # weed/filer/filechunk_manifest.go # weed/filer/stream.go # weed/replication/repl_util/replication_util.go # weed/util/fasthttp_util.go
Diffstat (limited to 'weed/filesys/filehandle.go')
-rw-r--r--weed/filesys/filehandle.go37
1 files changed, 20 insertions, 17 deletions
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index be214c02d..25eaf7033 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -6,6 +6,7 @@ import (
"io"
"math"
"net/http"
+ "os"
"sync"
"time"
@@ -41,7 +42,7 @@ func newFileHandle(file *File, uid, gid uint32) *FileHandle {
}
entry := fh.f.getEntry()
if entry != nil {
- entry.Attr.FileSize = filer.FileSize2(entry)
+ entry.Attributes.FileSize = filer.FileSize(entry)
}
return fh
@@ -109,7 +110,7 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {
return 0, io.EOF
}
- fileSize := int64(filer.FileSize2(entry))
+ fileSize := int64(filer.FileSize(entry))
fileFullPath := fh.f.fullpath()
if fileSize == 0 {
@@ -170,7 +171,7 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f
}
entry.Content = nil
- entry.Attr.FileSize = uint64(max(req.Offset+int64(len(data)), int64(entry.Attr.FileSize)))
+ entry.Attributes.FileSize = uint64(max(req.Offset+int64(len(data)), int64(entry.Attributes.FileSize)))
glog.V(4).Infof("%v write [%d,%d) %d", fh.f.fullpath(), req.Offset, req.Offset+int64(len(req.Data)), len(req.Data))
fh.dirtyPages.AddPage(req.Offset, data)
@@ -258,24 +259,26 @@ func (fh *FileHandle) doFlush(ctx context.Context, header fuse.Header) error {
return nil
}
- entry.Attr.Mime = fh.contentType
- if entry.Attr.Uid == 0 {
- entry.Attr.Uid = header.Uid
- }
- if entry.Attr.Gid == 0 {
- entry.Attr.Gid = header.Gid
- }
- if entry.Attr.Crtime.IsZero() {
- entry.Attr.Crtime = time.Now()
+ if entry.Attributes != nil {
+ entry.Attributes.Mime = fh.contentType
+ if entry.Attributes.Uid == 0 {
+ entry.Attributes.Uid = header.Uid
+ }
+ if entry.Attributes.Gid == 0 {
+ entry.Attributes.Gid = header.Gid
+ }
+ if entry.Attributes.Crtime == 0 {
+ entry.Attributes.Crtime = time.Now().Unix()
+ }
+ entry.Attributes.Mtime = time.Now().Unix()
+ entry.Attributes.FileMode = uint32(os.FileMode(entry.Attributes.FileMode) &^ fh.f.wfs.option.Umask)
+ entry.Attributes.Collection = fh.dirtyPages.collection
+ entry.Attributes.Replication = fh.dirtyPages.replication
}
- entry.Attr.Mtime = time.Now()
- entry.Attr.Mode = entry.Attr.Mode &^ fh.f.wfs.option.Umask
- entry.Attr.Collection = fh.dirtyPages.collection
- entry.Attr.Replication = fh.dirtyPages.replication
request := &filer_pb.CreateEntryRequest{
Directory: fh.f.dir.FullPath(),
- Entry: entry.ToProtoEntry(),
+ Entry: entry,
Signatures: []int32{fh.f.wfs.signature},
}