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
mount: able to trim a file
Chris Lu630f72f8c577
diff --git a/weed/filesys/file.go b/weed/filesys/file.goindex 7e562eabcd..622ba6f57f 100644--- a/weed/filesys/file.go+++ b/weed/filesys/file.go@@ -102,9 +102,18 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fif req.Valid.Size() {glog.V(3).Infof("%v file setattr set size=%v", file.fullpath(), req.Size)- if req.Size == 0 {+ if req.Size < filer2.TotalSize(file.entry.Chunks) {// fmt.Printf("truncate %v \n", fullPath)- file.entry.Chunks = nil+ var chunks []*filer_pb.FileChunk+ for _, chunk := range file.entry.Chunks {+ if uint64(chunk.Offset)+chunk.Size > req.Size {+ chunk.Size = req.Size - uint64(chunk.Offset)+ }+ if chunk.Size > 0 {+ chunks = append(chunks, chunk)+ }+ }+ file.entry.Chunks = chunksfile.entryViewCache = nil}file.entry.Attributes.FileSize = req.Size