Commit 3e91a7eb authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

IDevice: Publicly expose DeviceRemovedException

parent 10053e90
......@@ -30,6 +30,16 @@ namespace medialibrary
namespace fs
{
class DeviceRemovedException : public std::runtime_error
{
public:
DeviceRemovedException() noexcept
: std::runtime_error( "The device containing this file/folder was removed" )
{
}
};
class IDevice
{
public:
......
......@@ -41,20 +41,6 @@
#include "probe/CrawlerProbe.h"
#include "utils/Filename.h"
namespace
{
class DeviceRemovedException : public std::runtime_error
{
public:
DeviceRemovedException() noexcept
: std::runtime_error( "A device was removed during the discovery" )
{
}
};
}
namespace medialibrary
{
......@@ -98,7 +84,7 @@ bool FsDiscoverer::discover( const std::string& entryPoint )
{
LOG_WARN( fsDirMrl, " discovery aborted (assuming banned folder): ", ex.what() );
}
catch ( DeviceRemovedException& )
catch ( fs::DeviceRemovedException& )
{
// Simply ignore, the device has already been marked as removed and the DB updated accordingly
LOG_INFO( "Discovery of ", fsDirMrl, " was stopped after the device was removed" );
......@@ -139,7 +125,7 @@ bool FsDiscoverer::reloadFolder( std::shared_ptr<Folder> f )
{
checkFolder( std::move( directory ), std::move( f ), false );
}
catch ( DeviceRemovedException& )
catch ( fs::DeviceRemovedException& )
{
LOG_INFO( "Reloading of ", mrl, " was stopped after the device was removed" );
return false;
......@@ -229,7 +215,7 @@ void FsDiscoverer::checkFolder( std::shared_ptr<fs::IDirectory> currentFolderFs,
device = currentFolderFs->device();
// The device presence flag will be changed in place, so simply retest it
if ( device == nullptr || device->isPresent() == false )
throw DeviceRemovedException();
throw fs::DeviceRemovedException();
LOG_INFO( "Device was not removed" );
}
// However if the device isn't removable, we want to:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment