simplify delta of file id, for multi-versioning of a file
git-svn-id: https://weed-fs.googlecode.com/svn/trunk@54 282b0af5-e82d-9cf1-ede4-77906d7719d0
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"pkg/util"
|
"pkg/util"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ func NewNeedle(r *http.Request) (n *Needle, e error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
part, _ := form.NextPart()
|
part, _ := form.NextPart()
|
||||||
|
log.Println("uploading file " + part.FileName())
|
||||||
data, _ := ioutil.ReadAll(part)
|
data, _ := ioutil.ReadAll(part)
|
||||||
n.Data = data
|
n.Data = data
|
||||||
|
|
||||||
@@ -52,7 +54,18 @@ func (n *Needle) ParsePath(fid string) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
delta := ""
|
||||||
|
deltaIndex := strings.LastIndex(fid, "_")
|
||||||
|
if deltaIndex > 0 {
|
||||||
|
fid, delta = fid[0:deltaIndex], fid[deltaIndex+1:]
|
||||||
|
}
|
||||||
n.Key, n.Cookie = ParseKeyHash(fid)
|
n.Key, n.Cookie = ParseKeyHash(fid)
|
||||||
|
if delta != "" {
|
||||||
|
d, e := strconv.ParseUint(delta, 10, 64)
|
||||||
|
if e == nil {
|
||||||
|
n.Key += d
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
func (n *Needle) Append(w io.Writer) uint32 {
|
func (n *Needle) Append(w io.Writer) uint32 {
|
||||||
header := make([]byte, 16)
|
header := make([]byte, 16)
|
||||||
|
|||||||
Reference in New Issue
Block a user