Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
11d37c9e
Commit
11d37c9e
authored
Sep 27, 2016
by
Hugo Beauzée-Luyssen
Browse files
IDiscoverer: Propagate FS errors
parent
69c27018
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/discoverer/IDiscoverer.h
View file @
11d37c9e
...
...
@@ -40,8 +40,8 @@ public:
//FIXME: This is currently false since there is no way of interrupting
//a discoverer thread
virtual
bool
discover
(
const
std
::
string
&
entryPoint
)
=
0
;
virtual
void
reload
()
=
0
;
virtual
void
reload
(
const
std
::
string
&
entryPoint
)
=
0
;
virtual
bool
reload
()
=
0
;
virtual
bool
reload
(
const
std
::
string
&
entryPoint
)
=
0
;
};
}
...
...
src/discoverer/FsDiscoverer.cpp
View file @
11d37c9e
...
...
@@ -72,11 +72,15 @@ bool FsDiscoverer::discover( const std::string &entryPoint )
return
addFolder
(
*
fsDir
,
nullptr
);
}
void
FsDiscoverer
::
reload
()
bool
FsDiscoverer
::
reload
()
{
LOG_INFO
(
"Reloading all folders"
);
// Start by checking if previously known devices have been plugged/unplugged
checkDevices
();
if
(
checkDevices
()
==
false
)
{
LOG_ERROR
(
"Refusing to reloading files with no storage device"
);
return
false
;
}
auto
rootFolders
=
Folder
::
fetchAll
(
m_ml
,
0
);
for
(
const
auto
&
f
:
rootFolders
)
{
...
...
@@ -89,16 +93,17 @@ void FsDiscoverer::reload()
}
checkFolder
(
*
folder
,
*
f
);
}
return
true
;
}
void
FsDiscoverer
::
reload
(
const
std
::
string
&
entryPoint
)
bool
FsDiscoverer
::
reload
(
const
std
::
string
&
entryPoint
)
{
LOG_INFO
(
"Reloading folder "
,
entryPoint
);
auto
folder
=
Folder
::
fromPath
(
m_ml
,
entryPoint
);
if
(
folder
==
nullptr
)
{
LOG_ERROR
(
"Can't reload "
,
entryPoint
,
": folder wasn't found in database"
);
return
;
return
false
;
}
auto
folderFs
=
m_fsFactory
->
createDirectory
(
folder
->
path
()
);
if
(
folderFs
==
nullptr
)
...
...
@@ -106,11 +111,13 @@ void FsDiscoverer::reload( const std::string& entryPoint )
LOG_ERROR
(
" Failed to create a fs::IDirectory representing "
,
folder
->
path
()
);
}
checkFolder
(
*
folderFs
,
*
folder
);
return
true
;
}
void
FsDiscoverer
::
checkDevices
()
bool
FsDiscoverer
::
checkDevices
()
{
m_fsFactory
->
refreshDevices
();
if
(
m_fsFactory
->
refreshDevices
()
==
false
)
return
false
;
auto
devices
=
Device
::
fetchAll
(
m_ml
);
for
(
auto
&
d
:
devices
)
{
...
...
@@ -126,6 +133,7 @@ void FsDiscoverer::checkDevices()
LOG_INFO
(
"Device "
,
d
->
uuid
(),
" unchanged"
);
}
}
return
true
;
}
void
FsDiscoverer
::
checkFolder
(
fs
::
IDirectory
&
currentFolderFs
,
Folder
&
currentFolder
)
const
...
...
src/discoverer/FsDiscoverer.h
View file @
11d37c9e
...
...
@@ -39,8 +39,8 @@ class FsDiscoverer : public IDiscoverer
public:
FsDiscoverer
(
std
::
shared_ptr
<
factory
::
IFileSystem
>
fsFactory
,
MediaLibrary
*
ml
,
IMediaLibraryCb
*
cb
);
virtual
bool
discover
(
const
std
::
string
&
entryPoint
)
override
;
virtual
void
reload
()
override
;
virtual
void
reload
(
const
std
::
string
&
entryPoint
)
override
;
virtual
bool
reload
()
override
;
virtual
bool
reload
(
const
std
::
string
&
entryPoint
)
override
;
private:
///
...
...
@@ -51,7 +51,7 @@ private:
void
checkFiles
(
fs
::
IDirectory
&
parentFolderFs
,
Folder
&
parentFolder
)
const
;
static
bool
hasDotNoMediaFile
(
const
fs
::
IDirectory
&
directory
);
bool
addFolder
(
fs
::
IDirectory
&
folder
,
Folder
*
parentFolder
)
const
;
void
checkDevices
();
bool
checkDevices
();
private:
MediaLibrary
*
m_ml
;
...
...
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