SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
create files correctly!
Chris Lu7ca505294267
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.goindex 4383fe62d1..732912a993 100644--- a/weed/filesys/dir.go+++ b/weed/filesys/dir.go@@ -21,6 +21,9 @@ type Dir struct {wfs *WFS}+var _ = fs.Node(&Dir{})+var _ = fs.HandleReadDirAller(&Dir{})+func (dir *Dir) Attr(context context.Context, attr *fuse.Attr) error {attr.Mode = os.ModeDir | 0777return nildiff --git a/weed/filesys/file.go b/weed/filesys/file.goindex 18fd05e1df..230ff272fa 100644--- a/weed/filesys/file.go+++ b/weed/filesys/file.go@@ -23,6 +23,7 @@ var _ = fs.HandleReadAller(&File{})// var _ = fs.HandleReader(&File{})var _ = fs.HandleFlusher(&File{})var _ = fs.HandleWriter(&File{})+var _ = fs.HandleReleaser(&File{})type File struct {Chunks []*filer_pb.FileChunk@@ -49,6 +50,7 @@ func (file *File) Attr(context context.Context, attr *fuse.Attr) error {glog.V(1).Infof("read file size: %v", request)resp, err := client.GetFileAttributes(context, request)if err != nil {+ glog.V(0).Infof("read file attributes %v: %v", request, err)return err}@@ -67,13 +69,17 @@ func (file *File) Attr(context context.Context, attr *fuse.Attr) error {attr.Mtime = time.Unix(attributes.Mtime, 0)attr.Gid = attributes.Gidattr.Uid = attributes.Uid+return nil}func (file *File) ReadAll(ctx context.Context) (content []byte, err error) {+ // fmt.Printf("read all file %+v/%v\n", file.dir.Path, file.Name)+if len(file.Chunks) == 0 {+ glog.V(0).Infof("empty file %v/%v", file.dir.Path, file.Name)return}@@ -109,7 +115,12 @@ func (file *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error {func (file *File) Flush(ctx context.Context, req *fuse.FlushRequest) error {// fflush works at file level// send the data to the OS- fmt.Printf("flush file %+v\n", req)+ glog.V(3).Infof("file flush %v", req)++ if len(file.Chunks) == 0 {+ glog.V(2).Infof("file flush skipping empty %v", req)+ return nil+ }err := file.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {@@ -134,7 +145,7 @@ func (file *File) Flush(ctx context.Context, req *fuse.FlushRequest) error {func (file *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error {// write the request to volume servers- fmt.Printf("write file %+v\n", req)+ // fmt.Printf("write file %+v\n", req)var fileId, host string@@ -178,5 +189,14 @@ func (file *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.Mtime: time.Now().UnixNano(),})+ resp.Size = int(uploadResult.Size)++ return nil+}++func (file *File) Release(ctx context.Context, req *fuse.ReleaseRequest) error {++ // fmt.Printf("release file %+v\n", req)+return nil}