| 11 | } |
| 12 | |
| 13 | void LibrariesUpdater::updateIfNeeded() |
| 14 | { |
| 15 | YACReaderLibraries libraries; |
| 16 | |
| 17 | libraries.load(); |
| 18 | |
| 19 | for (const QString &name : libraries.getNames()) { |
| 20 | QString libraryPath = libraries.getPath(name); |
| 21 | QString libraryDataPath = YACReader::LibraryPaths::libraryDataPath(libraryPath); |
| 22 | QString databasePath = YACReader::LibraryPaths::libraryDatabasePath(libraryPath); |
| 23 | |
| 24 | QDir d; |
| 25 | |
| 26 | QString dbVersion; |
| 27 | if (d.exists(libraryDataPath) && d.exists(databasePath) && (dbVersion = DataBaseManagement::checkValidDB(databasePath)) != "") { |
| 28 | int comparation = DataBaseManagement::compareVersions(dbVersion, DB_VERSION); |
| 29 | |
| 30 | if (comparation < 0) { |
| 31 | bool updated = DataBaseManagement::updateToCurrentVersion(libraryPath); |
| 32 | if (!updated) { |
| 33 | // TODO log error |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | } |