Subsonic API: added the getScanStatus and startScan commands. fixes #62
This commit is contained in:
@@ -310,7 +310,7 @@ MediaScanner::getStatus()
|
||||
{
|
||||
Status res;
|
||||
|
||||
std::unique_lock<std::mutex> lock {_statusMutex};
|
||||
std::shared_lock lock {_statusMutex};
|
||||
|
||||
res.currentState = _curState;
|
||||
res.nextScheduledScan = _nextScheduledScan;
|
||||
@@ -367,7 +367,7 @@ MediaScanner::scheduleNextScan()
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock {_statusMutex};
|
||||
std::unique_lock lock {_statusMutex};
|
||||
_curState = nextScanDateTime.isValid() ? State::Scheduled : State::NotScheduled;
|
||||
_nextScheduledScan = nextScanDateTime;
|
||||
}
|
||||
@@ -421,8 +421,10 @@ MediaScanner::scan(boost::system::error_code err)
|
||||
if (err)
|
||||
return;
|
||||
|
||||
scanStarted().emit();
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock {_statusMutex};
|
||||
std::unique_lock lock {_statusMutex};
|
||||
_curState = State::InProgress;
|
||||
_nextScheduledScan = {};
|
||||
}
|
||||
@@ -464,7 +466,7 @@ MediaScanner::scan(boost::system::error_code err)
|
||||
{
|
||||
stats.stopTime = Wt::WLocalDateTime::currentDateTime().toUTC();
|
||||
{
|
||||
std::unique_lock<std::mutex> lock {_statusMutex};
|
||||
std::unique_lock lock {_statusMutex};
|
||||
|
||||
_lastCompleteScanStats = std::move(stats);
|
||||
_inProgressScanStats.reset();
|
||||
@@ -476,7 +478,7 @@ MediaScanner::scan(boost::system::error_code err)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unique_lock<std::mutex> lock {_statusMutex};
|
||||
std::unique_lock lock {_statusMutex};
|
||||
|
||||
_curState = State::NotScheduled;
|
||||
_inProgressScanStats.reset();
|
||||
@@ -584,13 +586,15 @@ MediaScanner::refreshScanSettings()
|
||||
void
|
||||
MediaScanner::notifyInProgress(const ScanStats& stats)
|
||||
{
|
||||
const ScanProgressStats progressStats {stats.toProgressStats()};
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock {_statusMutex};
|
||||
_inProgressScanStats = stats.toProgressStats();
|
||||
std::unique_lock lock {_statusMutex};
|
||||
_inProgressScanStats = progressStats;
|
||||
}
|
||||
|
||||
std::chrono::system_clock::time_point now {std::chrono::system_clock::now()};
|
||||
_sigScanInProgress(*_inProgressScanStats);
|
||||
const std::chrono::system_clock::time_point now {std::chrono::system_clock::now()};
|
||||
_sigScanInProgress(progressStats);
|
||||
_lastScanInProgressEmit = now;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user