Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-datastore
Commits
f098817c
Commit
f098817c
authored
Jun 28, 2016
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
omit slash from created dskeys, fix prefixLen discrepancy
parent
7a618be1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
flatfs/flatfs.go
flatfs/flatfs.go
+3
-2
flatfs/flatfs_test.go
flatfs/flatfs_test.go
+1
-1
No files found.
flatfs/flatfs.go
View file @
f098817c
...
...
@@ -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
}
...
...
flatfs/flatfs_test.go
View file @
f098817c
...
...
@@ -152,7 +152,7 @@ func TestStorage(t *testing.T) {
defer
cleanup
()
const
prefixLen
=
2
const
prefix
=
"q"
const
prefix
=
"q
u
"
const
target
=
prefix
+
string
(
os
.
PathSeparator
)
+
"quux.data"
fs
,
err
:=
flatfs
.
New
(
temp
,
prefixLen
,
false
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment