mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -04:00
Directory monitoring tracks invalid ZIM files too
A ZIM file that failed to be added to the library isn't just discarded by directory monitoring but is added to the set of known ZIM files with a proper status. This enables to process updates to such files more efficiently (coming next).
This commit is contained in:
parent
bc05c75448
commit
9548c9b778
@ -945,16 +945,19 @@ bool ContentManager::handleZimFileInMonitoredDirLogged(QString dir, QString file
|
||||
int ContentManager::handleZimFileInMonitoredDir(QString dir, QString fileName)
|
||||
{
|
||||
const auto bookPath = QDir::toNativeSeparators(dir + "/" + fileName);
|
||||
kiwix::Manager manager(mp_library->getKiwixLibrary());
|
||||
|
||||
if ( mp_library->isBeingDownloadedByUs(bookPath) ) {
|
||||
return MonitoredZimFileInfo::BEING_DOWNLOADED_BY_US;
|
||||
} else if ( manager.addBookFromPath(bookPath.toStdString()) ) {
|
||||
m_knownZimsInDir[dir].insert(fileName, MonitoredZimFileInfo());
|
||||
return MonitoredZimFileInfo::ADDED_TO_THE_LIBRARY;
|
||||
} else {
|
||||
return MonitoredZimFileInfo::COULD_NOT_BE_ADDED_TO_THE_LIBRARY;
|
||||
}
|
||||
|
||||
MonitoredZimFileInfo zfi;
|
||||
kiwix::Manager manager(mp_library->getKiwixLibrary());
|
||||
const bool addedToLib = manager.addBookFromPath(bookPath.toStdString());
|
||||
zfi.status = addedToLib
|
||||
? MonitoredZimFileInfo::ADDED_TO_THE_LIBRARY
|
||||
: MonitoredZimFileInfo::COULD_NOT_BE_ADDED_TO_THE_LIBRARY;
|
||||
m_knownZimsInDir[dir].insert(fileName, zfi);
|
||||
return zfi.status;
|
||||
}
|
||||
|
||||
ContentManager::QStringSet ContentManager::getLibraryZims(QString dirPath) const
|
||||
|
@ -113,6 +113,9 @@ private: // types
|
||||
{
|
||||
enum ZimFileStatus
|
||||
{
|
||||
// try to add this file to the library right away
|
||||
NO_INFO,
|
||||
|
||||
// the file is known to be downloaded by our own download manager
|
||||
BEING_DOWNLOADED_BY_US,
|
||||
|
||||
@ -123,7 +126,7 @@ private: // types
|
||||
COULD_NOT_BE_ADDED_TO_THE_LIBRARY
|
||||
};
|
||||
|
||||
ZimFileStatus status = ADDED_TO_THE_LIBRARY;
|
||||
ZimFileStatus status = NO_INFO;
|
||||
};
|
||||
|
||||
typedef QMap<QString, MonitoredZimFileInfo> ZimFileName2InfoMap;
|
||||
|
Loading…
x
Reference in New Issue
Block a user