Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
e2589947
Commit
e2589947
authored
Dec 15, 2015
by
Hugo Beauzée-Luyssen
Browse files
FsDiscoverer: Factorization
parent
9976a6c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/discoverer/FsDiscoverer.cpp
View file @
e2589947
...
...
@@ -65,10 +65,7 @@ bool FsDiscoverer::discover( const std::string &entryPoint )
return
false
;
}
auto
blist
=
blacklist
();
auto
it
=
std
::
find_if
(
begin
(
blist
),
end
(
blist
),
[
&
fsDir
](
const
std
::
shared_ptr
<
Folder
>&
f
)
{
return
f
->
path
()
==
fsDir
->
path
();
});
if
(
it
!=
end
(
blist
)
)
if
(
isBlacklisted
(
fsDir
->
path
(),
blist
)
==
true
)
return
false
;
// Force <0> as lastModificationDate, so this folder is detected as outdated
// by the modification checking code
...
...
@@ -135,10 +132,7 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, FolderPtr parentFold
if
(
it
==
end
(
subFoldersInDB
)
)
{
// Check if it is blacklisted
auto
it
=
std
::
find_if
(
begin
(
blacklist
),
end
(
blacklist
),
[
subFolderPath
](
const
std
::
shared_ptr
<
Folder
>&
f
)
{
return
f
->
path
()
==
subFolderPath
;
});
if
(
it
!=
end
(
blacklist
)
)
if
(
isBlacklisted
(
subFolderPath
,
blacklist
)
==
true
)
{
LOG_INFO
(
"Ignoring blacklisted folder: "
,
subFolderPath
);
continue
;
...
...
@@ -215,3 +209,10 @@ std::vector<std::shared_ptr<Folder> > FsDiscoverer::blacklist() const
static
const
std
::
string
req
=
"SELECT * FROM "
+
policy
::
FolderTable
::
Name
+
" WHERE is_blacklisted = 1"
;
return
sqlite
::
Tools
::
fetchAll
<
Folder
,
Folder
>
(
m_dbConn
,
req
);
}
bool
FsDiscoverer
::
isBlacklisted
(
const
std
::
string
&
path
,
const
std
::
vector
<
std
::
shared_ptr
<
Folder
>>&
blacklist
)
const
{
return
std
::
find_if
(
begin
(
blacklist
),
end
(
blacklist
),
[
&
path
](
const
std
::
shared_ptr
<
Folder
>&
f
)
{
return
path
==
f
->
path
();
})
!=
end
(
blacklist
);
}
src/discoverer/FsDiscoverer.h
View file @
e2589947
...
...
@@ -42,6 +42,7 @@ private:
bool
checkSubfolders
(
fs
::
IDirectory
*
folder
,
FolderPtr
parentFolder
,
const
std
::
vector
<
std
::
shared_ptr
<
Folder
>
>
blacklist
);
void
checkFiles
(
fs
::
IDirectory
*
folder
,
FolderPtr
parentFolder
);
std
::
vector
<
std
::
shared_ptr
<
Folder
>>
blacklist
()
const
;
bool
isBlacklisted
(
const
std
::
string
&
path
,
const
std
::
vector
<
std
::
shared_ptr
<
Folder
>>&
blacklist
)
const
;
private:
MediaLibrary
*
m_ml
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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