works now!
git-svn-id: https://weed-fs.googlecode.com/svn/trunk@20 282b0af5-e82d-9cf1-ede4-77906d7719d0
This commit is contained in:
@@ -2,6 +2,7 @@ package directory
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"log"
|
||||
"storage"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -16,21 +17,15 @@ type FileId struct {
|
||||
func NewFileId(VolumeId uint32, Key uint64, Hashcode uint32) *FileId {
|
||||
return &FileId{VolumeId: VolumeId, Key: Key, Hashcode: Hashcode}
|
||||
}
|
||||
|
||||
func ParseFileId(path string) *FileId {
|
||||
a := strings.Split(path, ",")
|
||||
func ParseFileId(fid string) *FileId {
|
||||
a := strings.Split(fid, ",")
|
||||
if len(a) != 2 {
|
||||
log.Println("Invalid fid", fid, ", split length", len(a))
|
||||
return nil
|
||||
}
|
||||
vid_string, key_hash_string := a[0], a[1]
|
||||
key_hash_bytes, khe := hex.DecodeString(key_hash_string)
|
||||
key_hash_len := len(key_hash_bytes)
|
||||
if khe != nil || key_hash_len <= 4 {
|
||||
return nil
|
||||
}
|
||||
vid, _ := strconv.Atoui64(vid_string)
|
||||
key := storage.BytesToUint64(key_hash_bytes[0 : key_hash_len-4])
|
||||
hash := storage.BytesToUint32(key_hash_bytes[key_hash_len-4 : key_hash_len])
|
||||
key, hash := storage.ParseKeyHash(key_hash_string)
|
||||
return &FileId{VolumeId: uint32(vid), Key: key, Hashcode: hash}
|
||||
}
|
||||
func (n *FileId) String() string {
|
||||
|
||||
Reference in New Issue
Block a user