|
|
@ -1,10 +1,11 @@ |
|
|
|
package storage |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.google.com/p/weed-fs/go/glog" |
|
|
|
"code.google.com/p/weed-fs/go/util" |
|
|
|
"encoding/hex" |
|
|
|
"errors" |
|
|
|
"strings" |
|
|
|
"code.google.com/p/weed-fs/go/glog" |
|
|
|
) |
|
|
|
|
|
|
|
type FileId struct { |
|
|
@ -16,16 +17,16 @@ type FileId struct { |
|
|
|
func NewFileId(VolumeId VolumeId, Key uint64, Hashcode uint32) *FileId { |
|
|
|
return &FileId{VolumeId: VolumeId, Key: Key, Hashcode: Hashcode} |
|
|
|
} |
|
|
|
func ParseFileId(fid string) *FileId { |
|
|
|
func ParseFileId(fid string) (*FileId, error) { |
|
|
|
a := strings.Split(fid, ",") |
|
|
|
if len(a) != 2 { |
|
|
|
glog.V(1).Infoln("Invalid fid ", fid, ", split length ", len(a)) |
|
|
|
return nil |
|
|
|
return nil, errors.New("Invalid fid " + fid) |
|
|
|
} |
|
|
|
vid_string, key_hash_string := a[0], a[1] |
|
|
|
volumeId, _ := NewVolumeId(vid_string) |
|
|
|
key, hash := ParseKeyHash(key_hash_string) |
|
|
|
return &FileId{VolumeId: volumeId, Key: key, Hashcode: hash} |
|
|
|
return &FileId{VolumeId: volumeId, Key: key, Hashcode: hash}, nil |
|
|
|
} |
|
|
|
func (n *FileId) String() string { |
|
|
|
bytes := make([]byte, 12) |
|
|
|