Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
aed5935e
Commit
aed5935e
authored
Jan 30, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use struct{} as value-type in dircache map
parent
b7c768d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
unionfs/dircache.go
unionfs/dircache.go
+9
-8
unionfs/unionfs.go
unionfs/unionfs.go
+3
-3
No files found.
unionfs/dircache.go
View file @
aed5935e
...
...
@@ -15,21 +15,21 @@ import (
// newDirnameMap reads the contents of the given directory. On error,
// returns a nil map. This forces reloads in the dirCache until we
// succeed.
func
newDirnameMap
(
fs
pathfs
.
FileSystem
,
dir
string
)
map
[
string
]
bool
{
func
newDirnameMap
(
fs
pathfs
.
FileSystem
,
dir
string
)
map
[
string
]
struct
{}
{
stream
,
code
:=
fs
.
OpenDir
(
dir
,
nil
)
if
code
==
fuse
.
ENOENT
{
// The directory not existing is not an error.
return
map
[
string
]
bool
{}
return
map
[
string
]
struct
{}
{}
}
if
!
code
.
Ok
()
{
return
nil
}
result
:=
make
(
map
[
string
]
bool
)
result
:=
make
(
map
[
string
]
struct
{}
)
for
_
,
e
:=
range
stream
{
if
e
.
Mode
&
fuse
.
S_IFREG
!=
0
{
result
[
e
.
Name
]
=
true
result
[
e
.
Name
]
=
struct
{}{}
}
}
return
result
...
...
@@ -47,11 +47,11 @@ type dirCache struct {
lock
sync
.
RWMutex
// If nil, you may call refresh() to schedule a new one.
names
map
[
string
]
bool
names
map
[
string
]
struct
{}
updateRunning
bool
}
func
(
c
*
dirCache
)
setMap
(
newMap
map
[
string
]
bool
)
{
func
(
c
*
dirCache
)
setMap
(
newMap
map
[
string
]
struct
{}
)
{
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
...
...
@@ -101,7 +101,7 @@ func (c *dirCache) AddEntry(name string) {
return
}
c
.
names
[
name
]
=
true
c
.
names
[
name
]
=
struct
{}{}
}
func
newDirCache
(
fs
pathfs
.
FileSystem
,
dir
string
,
ttl
time
.
Duration
)
*
dirCache
{
...
...
@@ -121,5 +121,6 @@ func (c *dirCache) HasEntry(name string) (mapPresent bool, found bool) {
return
false
,
false
}
return
true
,
c
.
names
[
name
]
_
,
ok
:=
c
.
names
[
name
]
return
true
,
ok
}
unionfs/unionfs.go
View file @
aed5935e
...
...
@@ -738,7 +738,7 @@ func (fs *unionFS) OpenDir(directory string, context *fuse.Context) (stream []fu
// We could try to use the cache, but we have a delay, so
// might as well get the fresh results async.
var
wg
sync
.
WaitGroup
var
deletions
map
[
string
]
bool
var
deletions
map
[
string
]
struct
{}
wg
.
Add
(
1
)
go
func
()
{
...
...
@@ -770,7 +770,7 @@ func (fs *unionFS) OpenDir(directory string, context *fuse.Context) (stream []fu
if
deletions
==
nil
{
_
,
code
:=
fs
.
fileSystems
[
0
]
.
GetAttr
(
fs
.
options
.
DeletionDirName
,
context
)
if
code
==
fuse
.
ENOENT
{
deletions
=
map
[
string
]
bool
{}
deletions
=
map
[
string
]
struct
{}
{}
}
else
{
return
nil
,
fuse
.
Status
(
syscall
.
EROFS
)
}
...
...
@@ -795,7 +795,7 @@ func (fs *unionFS) OpenDir(directory string, context *fuse.Context) (stream []fu
continue
}
deleted
:=
deletions
[
filePathHash
(
filepath
.
Join
(
directory
,
k
))]
_
,
deleted
:=
deletions
[
filePathHash
(
filepath
.
Join
(
directory
,
k
))]
if
!
deleted
{
results
[
k
]
=
v
}
...
...
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