diff --git a/src/file/fileindexerconfig.h b/src/file/fileindexerconfig.h --- a/src/file/fileindexerconfig.h +++ b/src/file/fileindexerconfig.h @@ -151,6 +151,11 @@ */ bool folderInFolderList(const QString& path, QString& folder) const; + /** + * Check if the device containing \p path is mounted. + */ + bool pathDeviceIsMounted(const QString& path); + /** * Returns the internal version number of the Baloo database */ diff --git a/src/file/fileindexerconfig.cpp b/src/file/fileindexerconfig.cpp --- a/src/file/fileindexerconfig.cpp +++ b/src/file/fileindexerconfig.cpp @@ -251,6 +251,21 @@ return false; } +bool FileIndexerConfig::pathDeviceIsMounted(const QString& path) +{ + if (!m_devices) { + m_devices = new StorageDevices(this); + } + + for (const auto& device: m_devices->allMedia()) { + const QString devicePath = device.mountPath() + QLatin1Char('/'); + if (device.isMounted() && path.startsWith(devicePath)) { + return true; + } + } + + return false; +} namespace {