mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Enter ContentManager::getMonitoredZimFileInfo()
At this point, the new function is just a stub. Indentation is not fixed intentionally (in order to minimize the diff).
This commit is contained in:
parent
9548c9b778
commit
b7d9b5d855
@ -942,6 +942,16 @@ bool ContentManager::handleZimFileInMonitoredDirLogged(QString dir, QString file
|
|||||||
return status == MonitoredZimFileInfo::ADDED_TO_THE_LIBRARY;
|
return status == MonitoredZimFileInfo::ADDED_TO_THE_LIBRARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContentManager::MonitoredZimFileInfo ContentManager::getMonitoredZimFileInfo(QString dir, QString fileName) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(dir);
|
||||||
|
Q_UNUSED(fileName);
|
||||||
|
// TODO: implement properly
|
||||||
|
MonitoredZimFileInfo zfi;
|
||||||
|
zfi.status = MonitoredZimFileInfo::PROCESS_NOW;
|
||||||
|
return zfi;
|
||||||
|
}
|
||||||
|
|
||||||
int ContentManager::handleZimFileInMonitoredDir(QString dir, QString fileName)
|
int ContentManager::handleZimFileInMonitoredDir(QString dir, QString fileName)
|
||||||
{
|
{
|
||||||
const auto bookPath = QDir::toNativeSeparators(dir + "/" + fileName);
|
const auto bookPath = QDir::toNativeSeparators(dir + "/" + fileName);
|
||||||
@ -950,13 +960,15 @@ int ContentManager::handleZimFileInMonitoredDir(QString dir, QString fileName)
|
|||||||
return MonitoredZimFileInfo::BEING_DOWNLOADED_BY_US;
|
return MonitoredZimFileInfo::BEING_DOWNLOADED_BY_US;
|
||||||
}
|
}
|
||||||
|
|
||||||
MonitoredZimFileInfo zfi;
|
MonitoredZimFileInfo zfi = getMonitoredZimFileInfo(dir, fileName);
|
||||||
|
if ( zfi.status == MonitoredZimFileInfo::PROCESS_NOW ) {
|
||||||
kiwix::Manager manager(mp_library->getKiwixLibrary());
|
kiwix::Manager manager(mp_library->getKiwixLibrary());
|
||||||
const bool addedToLib = manager.addBookFromPath(bookPath.toStdString());
|
const bool addedToLib = manager.addBookFromPath(bookPath.toStdString());
|
||||||
zfi.status = addedToLib
|
zfi.status = addedToLib
|
||||||
? MonitoredZimFileInfo::ADDED_TO_THE_LIBRARY
|
? MonitoredZimFileInfo::ADDED_TO_THE_LIBRARY
|
||||||
: MonitoredZimFileInfo::COULD_NOT_BE_ADDED_TO_THE_LIBRARY;
|
: MonitoredZimFileInfo::COULD_NOT_BE_ADDED_TO_THE_LIBRARY;
|
||||||
m_knownZimsInDir[dir].insert(fileName, zfi);
|
m_knownZimsInDir[dir].insert(fileName, zfi);
|
||||||
|
}
|
||||||
return zfi.status;
|
return zfi.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ private: // types
|
|||||||
enum ZimFileStatus
|
enum ZimFileStatus
|
||||||
{
|
{
|
||||||
// try to add this file to the library right away
|
// try to add this file to the library right away
|
||||||
NO_INFO,
|
PROCESS_NOW,
|
||||||
|
|
||||||
// the file is known to be downloaded by our own download manager
|
// the file is known to be downloaded by our own download manager
|
||||||
BEING_DOWNLOADED_BY_US,
|
BEING_DOWNLOADED_BY_US,
|
||||||
@ -126,7 +126,7 @@ private: // types
|
|||||||
COULD_NOT_BE_ADDED_TO_THE_LIBRARY
|
COULD_NOT_BE_ADDED_TO_THE_LIBRARY
|
||||||
};
|
};
|
||||||
|
|
||||||
ZimFileStatus status = NO_INFO;
|
ZimFileStatus status = PROCESS_NOW;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QMap<QString, MonitoredZimFileInfo> ZimFileName2InfoMap;
|
typedef QMap<QString, MonitoredZimFileInfo> ZimFileName2InfoMap;
|
||||||
@ -146,6 +146,7 @@ private: // functions
|
|||||||
size_t handleNewZimFiles(const QString& dirPath, const QStringSet& fileNames);
|
size_t handleNewZimFiles(const QString& dirPath, const QStringSet& fileNames);
|
||||||
bool handleZimFileInMonitoredDirLogged(QString dirPath, QString fileName);
|
bool handleZimFileInMonitoredDirLogged(QString dirPath, QString fileName);
|
||||||
int handleZimFileInMonitoredDir(QString dirPath, QString fileName);
|
int handleZimFileInMonitoredDir(QString dirPath, QString fileName);
|
||||||
|
MonitoredZimFileInfo getMonitoredZimFileInfo(QString dir, QString fileName) const;
|
||||||
bool handleDisappearedBook(QString bookId);
|
bool handleDisappearedBook(QString bookId);
|
||||||
|
|
||||||
// Get the book with the specified id from
|
// Get the book with the specified id from
|
||||||
|
Loading…
x
Reference in New Issue
Block a user