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
495c8396
Commit
495c8396
authored
Sep 27, 2016
by
Hugo Beauzée-Luyssen
Browse files
factory: IFileSystem: Return an error when no devices are found
parent
ab68f490
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/factory/IFileSystem.h
View file @
495c8396
...
...
@@ -61,7 +61,7 @@ namespace factory
///
/// \brief refresh Will cause any FS cache to be refreshed.
///
virtual
void
refreshDevices
()
=
0
;
virtual
bool
refreshDevices
()
=
0
;
};
}
...
...
src/factory/FileSystemFactory.cpp
View file @
495c8396
...
...
@@ -99,7 +99,7 @@ std::shared_ptr<fs::IDevice> FileSystemFactory::createDeviceFromPath( const std:
return
res
;
}
void
FileSystemFactory
::
refreshDevices
()
bool
FileSystemFactory
::
refreshDevices
()
{
{
std
::
lock_guard
<
compat
::
Mutex
>
lock
(
m_mutex
);
...
...
@@ -110,6 +110,11 @@ void FileSystemFactory::refreshDevices()
m_deviceCache
=
DeviceCacheMap
{};
m_deviceCache
.
get
().
clear
();
auto
devices
=
m_deviceLister
->
devices
();
if
(
devices
.
empty
()
==
true
)
{
LOG_ERROR
(
"Cannot continue with no devices"
);
return
false
;
}
for
(
const
auto
&
d
:
devices
)
{
const
auto
&
uuid
=
std
::
get
<
0
>
(
d
);
...
...
@@ -117,6 +122,7 @@ void FileSystemFactory::refreshDevices()
const
auto
removable
=
std
::
get
<
2
>
(
d
);
m_deviceCache
.
get
().
emplace
(
uuid
,
std
::
make_shared
<
fs
::
Device
>
(
uuid
,
mountpoint
,
removable
)
);
}
return
true
;
}
}
...
...
src/factory/FileSystemFactory.h
View file @
495c8396
...
...
@@ -45,7 +45,7 @@ namespace factory
virtual
std
::
shared_ptr
<
fs
::
IDirectory
>
createDirectory
(
const
std
::
string
&
path
)
override
;
virtual
std
::
shared_ptr
<
fs
::
IDevice
>
createDevice
(
const
std
::
string
&
uuid
)
override
;
virtual
std
::
shared_ptr
<
fs
::
IDevice
>
createDeviceFromPath
(
const
std
::
string
&
path
)
override
;
virtual
void
refreshDevices
()
override
;
virtual
bool
refreshDevices
()
override
;
private:
std
::
unordered_map
<
std
::
string
,
std
::
shared_ptr
<
fs
::
IDirectory
>>
m_dirs
;
...
...
test/mocks/FileSystem.h
View file @
495c8396
...
...
@@ -177,7 +177,10 @@ struct FileSystemFactory : public factory::IFileSystem
return
*
it
;
}
virtual
void
refreshDevices
()
override
{}
virtual
bool
refreshDevices
()
override
{
return
false
;
}
std
::
shared_ptr
<
Device
>
device
(
const
std
::
string
&
path
)
{
...
...
@@ -315,8 +318,9 @@ public:
return
nullptr
;
}
virtual
void
refreshDevices
()
override
virtual
bool
refreshDevices
()
override
{
return
false
;
}
};
...
...
Write
Preview
Supports
Markdown
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