##// END OF EJS Templates
Fix the loading of the default database
trabillard -
r1126:4b00ad8b6024
parent child
Show More
@@ -19,7 +19,7
19 19
20 20 Q_LOGGING_CATEGORY(LOG_CatalogueController, "CatalogueController")
21 21
22 namespace {
22 namespace {
23 23
24 24 static QString REPOSITORY_WORK_SUFFIX = QString{"Work"};
25 25
@@ -63,9 +63,8 void CatalogueController::addDB(const QString &dbPath)
63 63 qCCritical(LOG_CatalogueController())
64 64 << tr("Impossible to addDB %1 from %2 ").arg(dirName, dbPath);
65 65 }
66 else
67 {
68 impl->m_RepositoryList << dirName;
66 else {
67 impl->m_RepositoryList.push_back(dirName);
69 68 }
70 69 }
71 70 else {
@@ -109,15 +108,24 void CatalogueController::initialize()
109 108 << QThread::currentThread();
110 109 impl->m_WorkingMutex.lock();
111 110 impl->m_CatalogueDao.initialize();
112 auto defaultRepository = QString("%1/%2").arg(
113 QStandardPaths::displayName(QStandardPaths::AppDataLocation), REPOSITORY_DEFAULT);
114 QDir defaultRepositoryDir(defaultRepository);
115 if (defaultRepositoryDir.exists()) {
116 qCInfo(LOG_CatalogueController()) << tr("Persistant data loading from: ")
117 << defaultRepository;
111 auto defaultRepositoryLocation
112 = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
113
114 QDir defaultRepositoryLocationDir;
115 if (defaultRepositoryLocationDir.mkpath(defaultRepositoryLocation)) {
116 defaultRepositoryLocationDir.cd(defaultRepositoryLocation);
117 auto defaultRepository = defaultRepositoryLocationDir.absoluteFilePath(REPOSITORY_DEFAULT);
118 qCInfo(LOG_CatalogueController())
119 << tr("Persistant data loading from: ") << defaultRepository;
118 120 this->addDB(defaultRepository);
119 qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END");
120 121 }
122 else {
123 qCWarning(LOG_CatalogueController())
124 << tr("Cannot load the persistent default repository from ")
125 << defaultRepositoryLocation;
126 }
127
128 qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END");
121 129 }
122 130
123 131 void CatalogueController::finalize()
General Comments 0
You need to be logged in to leave comments. Login now