aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-05-30 20:24:57 -0700
committerChris Lu <chris.lu@gmail.com>2018-05-30 20:24:57 -0700
commit0301504184fa3342624c70b9066dfbfb7944af25 (patch)
treecafb52daf1659a5fd28fdc0e0bc58d328f62178b /weed/filesys
parent26e7cd8c7537dc010e6757060c1835a342fffc90 (diff)
downloadseaweedfs-0301504184fa3342624c70b9066dfbfb7944af25.tar.xz
seaweedfs-0301504184fa3342624c70b9066dfbfb7944af25.zip
add mime, use simple insert and update filer store API
1. add mime type to file in filer 2. purge old chunks if overwrite during insert
Diffstat (limited to 'weed/filesys')
-rw-r--r--weed/filesys/filehandle.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index 9fa971236..32e4622d0 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -11,6 +11,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/util"
"strings"
"sync"
+ "net/http"
)
type FileHandle struct {
@@ -18,10 +19,6 @@ type FileHandle struct {
dirtyPages *ContinuousDirtyPages
dirtyMetadata bool
- cachePath string
-
- handle uint64
-
f *File
RequestId fuse.RequestID // unique ID for request
NodeId fuse.NodeID // file or directory the request is about
@@ -135,6 +132,11 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f
resp.Size = len(req.Data)
+ if req.Offset == 0 {
+ fh.f.attributes.Mime = http.DetectContentType(req.Data)
+ fh.dirtyMetadata = true
+ }
+
if chunk != nil {
fh.f.Chunks = append(fh.f.Chunks, chunk)
glog.V(1).Infof("uploaded %s/%s to %s [%d,%d)", fh.f.dir.Path, fh.f.Name, chunk.FileId, chunk.Offset, chunk.Offset+int64(chunk.Size))