Skip to content

Commit

Permalink
Merge pull request #41 from ipfs/fix/omit-slash
Browse files Browse the repository at this point in the history
omit slash from created dskeys
  • Loading branch information
whyrusleeping authored Jun 28, 2016
2 parents 7a618be + f098817 commit 4d340af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions flatfs/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/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 4d340af

Please sign in to comment.