Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
scan-filesystem
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
scan-filesystem
Commits
3094dd56
Commit
3094dd56
authored
Oct 10, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify scan-filsystem
parent
4ffdaae6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
32 deletions
+6
-32
cython/main.pyx
cython/main.pyx
+6
-32
No files found.
cython/main.pyx
View file @
3094dd56
...
...
@@ -33,7 +33,7 @@ cdef cypclass Node activable:
self
.
path
=
path
self
.
stat
=
stat
void
build_node
(
self
,
lock
List
[
dev_t
]
dev_whitelist
,
lock
List
[
Str
]
ignore_paths
):
pass
void
build_node
(
self
):
pass
void
format_node
(
self
):
self
.
json
=
format
(
"""
\
...
...
@@ -76,17 +76,7 @@ cdef cypclass DirNode(Node):
Node
.
__init__
(
self
,
path
,
stat
)
self
.
children
=
Children
()
void
build_node
(
self
,
lock
List
[
dev_t
]
dev_whitelist
,
lock
List
[
Str
]
ignore_paths
):
if
ignore_paths
is
not
NULL
:
if
consume
self
.
path
.
copy
()
in
ignore_paths
:
return
if
dev_whitelist
is
not
NULL
:
if
self
.
stat
is
NULL
:
return
elif
not
self
.
stat
.
st_data
.
st_dev
in
dev_whitelist
:
return
void
build_node
(
self
):
entries
=
sys
.
listdir
(
self
.
path
)
if
entries
is
not
NULL
:
for
name
in
entries
:
...
...
@@ -104,7 +94,7 @@ cdef cypclass DirNode(Node):
self
.
format_node
()
for
active_child
in
self
.
children
:
active_child
.
build_node
(
NULL
,
dev_whitelist
,
ignore_paths
)
active_child
.
build_node
(
NULL
)
void
write_node
(
self
,
FILE
*
stream
):
sys
.
write
(
self
.
json
,
stream
)
...
...
@@ -129,7 +119,7 @@ cdef cypclass FileNode(Node):
Node
.
__init__
(
self
,
path
,
stat
)
self
.
error
=
False
void
build_node
(
self
,
lock
List
[
dev_t
]
dev_whitelist
,
lock
List
[
Str
]
ignore_paths
):
void
build_node
(
self
):
cdef
bint
md5_ok
cdef
bint
sha1_ok
cdef
bint
sha256_ok
...
...
@@ -208,7 +198,7 @@ cdef cypclass FileNode(Node):
cdef
cypclass
SymlinkNode
(
Node
):
Str
target
void
build_node
(
self
,
lock
List
[
dev_t
]
dev_whitelist
,
lock
List
[
Str
]
ignore_paths
):
void
build_node
(
self
):
self
.
target
=
sys
.
readlink
(
self
.
path
,
self
.
stat
.
st_data
.
st_size
)
self
.
format_node
()
...
...
@@ -234,29 +224,13 @@ cdef cypclass SymlinkNode(Node):
cdef
int
scan
(
iso
Str
root
)
nogil
:
ignore_paths
=
List
[
Str
]()
ignore_paths
.
append
(
Str
(
"/opt/slapgrid"
))
ignore_paths
.
append
(
Str
(
"/srv/slapgrid"
))
dev_whitelist_paths
=
List
[
Str
]()
dev_whitelist_paths
.
append
(
Str
(
"."
))
dev_whitelist_paths
.
append
(
Str
(
"/"
))
dev_whitelist_paths
.
append
(
Str
(
"/boot"
))
dev_whitelist
=
List
[
dev_t
]()
for
p
in
dev_whitelist_paths
:
p_stat
=
Stat
(
p
)
if
p_stat
is
not
NULL
:
p_dev
=
p_stat
.
st_data
.
st_dev
dev_whitelist
.
append
(
p_dev
)
node
=
make_node
(
consume
root
)
if
node
is
NULL
:
return
-
1
active_node
=
activate
(
consume
node
)
active_node
.
build_node
(
NULL
,
consume
dev_whitelist
,
consume
ignore_paths
)
active_node
.
build_node
(
NULL
)
scheduler
.
join
()
...
...
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