mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Refresh library with monitory directory changes on startup
This refreshes the library on every startup list of elements already in monitor directory (before changes) are taken by filtering library.xml
This commit is contained in:
parent
45a09cfae6
commit
e0337d0caf
@ -101,6 +101,11 @@ void KiwixApp::init()
|
||||
this->openZimFile(message);
|
||||
}
|
||||
});
|
||||
QString monitorDir = m_settingsManager.getMonitorDir();
|
||||
if (monitorDir != "") {
|
||||
m_library.setMonitorDirZims(m_library.getLibraryZimsFromDir(monitorDir));
|
||||
m_library.asyncLoadMonitorDir(monitorDir);
|
||||
}
|
||||
}
|
||||
|
||||
KiwixApp::~KiwixApp()
|
||||
|
@ -130,6 +130,19 @@ void Library::setMonitorDirZims(QStringList zimList)
|
||||
m_monitorDirZims = zimList;
|
||||
}
|
||||
|
||||
QStringList Library::getLibraryZimsFromDir(QString dir) const
|
||||
{
|
||||
QStringList zimsInDir;
|
||||
for (auto str : getBookIds()) {
|
||||
auto filePath = QString::fromStdString(getBookById(str).getPath());
|
||||
QDir absoluteDir = QFileInfo(filePath).absoluteDir();
|
||||
if (absoluteDir == dir) {
|
||||
zimsInDir.push_back(filePath);
|
||||
}
|
||||
}
|
||||
return zimsInDir;
|
||||
}
|
||||
|
||||
void Library::loadMonitorDir(QString monitorDir)
|
||||
{
|
||||
QMutex mutex;
|
||||
|
Loading…
x
Reference in New Issue
Block a user