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
fa882e4c
Commit
fa882e4c
authored
Dec 31, 2015
by
Hugo Beauzée-Luyssen
Browse files
IFileSystem: Add a refresh method
And use it to force a device cache refresh
parent
2a9d5b4c
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/factory/IFileSystem.h
View file @
fa882e4c
...
...
@@ -54,5 +54,9 @@ namespace factory
/// \return A representation of the device, or nullptr if the device is currently unavailable.
///
virtual
std
::
shared_ptr
<
fs
::
IDevice
>
createDevice
(
const
std
::
string
&
uuid
)
=
0
;
///
/// \brief refresh Will cause any FS cache to be refreshed.
///
virtual
void
refresh
()
=
0
;
};
}
src/discoverer/FsDiscoverer.cpp
View file @
fa882e4c
...
...
@@ -88,6 +88,7 @@ void FsDiscoverer::reload()
void
FsDiscoverer
::
checkDevices
()
{
m_fsFactory
->
refresh
();
auto
devices
=
Device
::
fetchAll
(
m_dbConn
);
for
(
auto
&
d
:
devices
)
{
...
...
src/factory/FileSystem.cpp
View file @
fa882e4c
...
...
@@ -41,9 +41,6 @@ namespace factory
FileSystemFactory
::
FileSystemFactory
()
{
static
bool
isCachePopulated
=
fs
::
Device
::
populateCache
();
if
(
isCachePopulated
==
false
)
throw
std
::
runtime_error
(
"Failed to populate device cache"
);
}
std
::
shared_ptr
<
fs
::
IDirectory
>
FileSystemFactory
::
createDirectory
(
const
std
::
string
&
path
)
...
...
@@ -75,6 +72,11 @@ std::shared_ptr<fs::IDevice> FileSystemFactory::createDevice( const std::string&
return
fs
::
Device
::
fromUuid
(
uuid
);
}
void
FileSystemFactory
::
refresh
()
{
fs
::
Device
::
populateCache
();
}
}
src/factory/FileSystem.h
View file @
fa882e4c
...
...
@@ -37,6 +37,7 @@ namespace factory
virtual
std
::
shared_ptr
<
fs
::
IDirectory
>
createDirectory
(
const
std
::
string
&
path
)
override
;
virtual
std
::
unique_ptr
<
fs
::
IFile
>
createFile
(
const
std
::
string
&
fileName
)
override
;
virtual
std
::
shared_ptr
<
fs
::
IDevice
>
createDevice
(
const
std
::
string
&
uuid
)
override
;
virtual
void
refresh
()
override
;
private:
std
::
unordered_map
<
std
::
string
,
std
::
shared_ptr
<
fs
::
IDirectory
>>
m_dirs
;
...
...
test/mocks/FileSystem.h
View file @
fa882e4c
...
...
@@ -464,6 +464,8 @@ struct FileSystemFactory : public factory::IFileSystem
return
*
it
;
}
virtual
void
refresh
()
override
{}
std
::
shared_ptr
<
Device
>
device
(
const
std
::
string
&
path
)
{
std
::
shared_ptr
<
Device
>
ret
;
...
...
@@ -599,6 +601,10 @@ public:
{
return
nullptr
;
}
virtual
void
refresh
()
override
{
}
};
}
...
...
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