Skip to content

Commit

Permalink
omit slash from created dskeys, fix prefixLen discrepancy
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Jun 28, 2016
1 parent dfe0659 commit 9121c86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions flatfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion flatfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9121c86

Please sign in to comment.