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
fix bug: upload a file which already existed return a wrong file size.
yanyiwu5a40f539f23b
diff --git a/go/storage/needle.go b/go/storage/needle.goindex 5b43576148..11610dd802 100644--- a/go/storage/needle.go+++ b/go/storage/needle.go@@ -25,6 +25,7 @@ const ()/*+* A Needle means a uploaded and stored file.* Needle file size is limited to 4GB for now.*/type Needle struct {diff --git a/go/storage/store.go b/go/storage/store.goindex 80d8a30b81..e1d9d2b018 100644--- a/go/storage/store.go+++ b/go/storage/store.go@@ -33,6 +33,10 @@ type MasterNodes struct {lastNode int}+func (mn *MasterNodes) String() string {+ return fmt.Sprintf("nodes:%v, lastNode:%d", mn.nodes, mn.lastNode)+}+func NewMasterNodes(bootstrapNode string) (mn *MasterNodes) {mn = &MasterNodes{nodes: []string{bootstrapNode}, lastNode: -1}return@@ -65,6 +69,9 @@ func (mn *MasterNodes) findMaster() (string, error) {return mn.nodes[mn.lastNode], nil}+/*+ * A VolumeServer contains one Store+ */type Store struct {Port intIp string@@ -77,6 +84,11 @@ type Store struct {masterNodes *MasterNodes}+func (s *Store) String() (str string) {+ str = fmt.Sprintf("Ip:%s, Port:%d, PublicUrl:%s, dataCenter:%s, rack:%s, connected:%v, volumeSizeLimit:%d, masterNodes:%s", s.Ip, s.Port, s.PublicUrl, s.dataCenter, s.rack, s.connected, s.volumeSizeLimit, s.masterNodes)+ return+}+func NewStore(port int, ip, publicUrl string, dirnames []string, maxVolumeCounts []int) (s *Store) {s = &Store{Port: port, Ip: ip, PublicUrl: publicUrl}s.Locations = make([]*DiskLocation, 0)diff --git a/go/storage/volume.go b/go/storage/volume.goindex 5b0a836054..a1eccd62ca 100644--- a/go/storage/volume.go+++ b/go/storage/volume.go@@ -33,6 +33,10 @@ func NewVolume(dirname string, collection string, id VolumeId, replicaPlacemente = v.load(true, true)return}+func (v *Volume) String() string {+ return fmt.Sprintf("Id:%v, dir:%s, Collection:%s, dataFile:%v, nm:%v, readOnly:%v", v.Id, v.dir, v.Collection, v.dataFile, v.nm, v.readOnly)+}+func loadVolumeWithoutIndex(dirname string, collection string, id VolumeId) (v *Volume, e error) {v = &Volume{dir: dirname, Collection: collection, Id: id}v.SuperBlock = SuperBlock{}@@ -135,7 +139,7 @@ func (v *Volume) isFileUnchanged(n *Needle) bool {oldNeedle := new(Needle)oldNeedle.Read(v.dataFile, int64(nv.Offset)*NeedlePaddingSize, nv.Size, v.Version())if oldNeedle.Checksum == n.Checksum && bytes.Equal(oldNeedle.Data, n.Data) {- n.Size = oldNeedle.Size+ n.DataSize = oldNeedle.DataSizereturn true}}@@ -165,7 +169,7 @@ func (v *Volume) write(n *Needle) (size uint32, err error) {v.accessLock.Lock()defer v.accessLock.Unlock()if v.isFileUnchanged(n) {- size = n.Size+ size = n.DataSizeglog.V(4).Infof("needle is unchanged!")return}