Commit f098817c authored by Jeromy's avatar Jeromy

omit slash from created dskeys, fix prefixLen discrepancy

parent 7a618be1
......@@ -56,9 +56,10 @@ func New(path string, prefixLen int, sync bool) (*Datastore, error) {
var padding = strings.Repeat("_", maxPrefixLen)
func (fs *Datastore) encode(key datastore.Key) (dir, file string) {
prefix := (key.String() + padding)[:fs.prefixLen]
noslash := key.String()[1:]
prefix := (noslash + padding)[:fs.prefixLen]
dir = path.Join(fs.path, prefix)
file = path.Join(dir, key.String()+extension)
file = path.Join(dir, noslash+extension)
return dir, file
}
......
......@@ -152,7 +152,7 @@ func TestStorage(t *testing.T) {
defer cleanup()
const prefixLen = 2
const prefix = "q"
const prefix = "qu"
const target = prefix + string(os.PathSeparator) + "quux.data"
fs, err := flatfs.New(temp, prefixLen, false)
if err != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment