mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactor functions
This commit is contained in:
parent
b1f083cb60
commit
a0955aa4dd
|
@ -14,6 +14,9 @@ type FileId struct {
|
|||
Hashcode uint32
|
||||
}
|
||||
|
||||
func NewFileIdFromNeedle(VolumeId VolumeId, n *Needle) *FileId {
|
||||
return &FileId{VolumeId: VolumeId, Key: n.Id, Hashcode: n.Cookie}
|
||||
}
|
||||
func NewFileId(VolumeId VolumeId, Key uint64, Hashcode uint32) *FileId {
|
||||
return &FileId{VolumeId: VolumeId, Key: Key, Hashcode: Hashcode}
|
||||
}
|
||||
|
|
|
@ -208,6 +208,7 @@ func (v *Volume) Destroy() (err error) {
|
|||
}
|
||||
|
||||
func (v *Volume) write(n *Needle) (size uint32, err error) {
|
||||
glog.V(4).Infof("writing needle %s", NewFileIdFromNeedle(v.Id, n).String())
|
||||
if v.readOnly {
|
||||
err = fmt.Errorf("%s is read-only", v.dataFile)
|
||||
return
|
||||
|
@ -249,6 +250,7 @@ func (v *Volume) write(n *Needle) (size uint32, err error) {
|
|||
}
|
||||
|
||||
func (v *Volume) delete(n *Needle) (uint32, error) {
|
||||
glog.V(4).Infof("delete needle %s", NewFileIdFromNeedle(v.Id, n).String())
|
||||
if v.readOnly {
|
||||
return 0, fmt.Errorf("%s is read-only", v.dataFile)
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ type nameParams struct {
|
|||
}
|
||||
|
||||
func walker(vid storage.VolumeId, n *storage.Needle, version storage.Version) (err error) {
|
||||
key := storage.NewFileId(vid, n.Id, n.Cookie).String()
|
||||
key := storage.NewFileIdFromNeedle(vid, n).String()
|
||||
if tarFh != nil {
|
||||
fnTmplBuf.Reset()
|
||||
if err = fnTmpl.Execute(fnTmplBuf,
|
||||
|
|
Loading…
Reference in a new issue