From f8c4dc0020e54d68b43a6d7ae1041ea01248fd51 2017-12-20 15:17:59 From: mperrinel Date: 2017-12-20 15:17:59 Subject: [PATCH] Add fix for default repository init --- diff --git a/core/include/Catalogue/CatalogueController.h b/core/include/Catalogue/CatalogueController.h index cf089e7..7681e08 100644 --- a/core/include/Catalogue/CatalogueController.h +++ b/core/include/Catalogue/CatalogueController.h @@ -41,8 +41,7 @@ public: /// retrieveEvents with empty repository retrieve them from the default repository std::list > retrieveEvents(const QString &repository) const; std::list > retrieveAllEvents() const; - std::list > - retrieveEventsFromCatalogue(std::shared_ptr catalogue) const; + void addEvent(std::shared_ptr event); void updateEvent(std::shared_ptr event); void updateEventProduct(std::shared_ptr eventProduct); @@ -54,6 +53,8 @@ public: bool eventHasChanges(std::shared_ptr event) const; // Catalogue + std::list > + retrieveEventsFromCatalogue(std::shared_ptr catalogue) const; // bool createCatalogue(const QString &name, QVector eventList); /// retrieveEvents with empty repository retrieve them from the default repository std::list > retrieveCatalogues(const QString &repository diff --git a/core/src/Catalogue/CatalogueController.cpp b/core/src/Catalogue/CatalogueController.cpp index 6ae79e0..83295c7 100644 --- a/core/src/Catalogue/CatalogueController.cpp +++ b/core/src/Catalogue/CatalogueController.cpp @@ -339,9 +339,23 @@ void CatalogueController::initialize() if (defaultRepositoryLocationDir.mkpath(defaultRepositoryLocation)) { defaultRepositoryLocationDir.cd(defaultRepositoryLocation); auto defaultRepository = defaultRepositoryLocationDir.absoluteFilePath(REPOSITORY_DEFAULT); + qCInfo(LOG_CatalogueController()) << tr("Persistant data loading from: ") << defaultRepository; - this->addDB(defaultRepository); + + QDir dbDir(defaultRepository); + impl->m_RepositoryList << REPOSITORY_DEFAULT; + if (dbDir.exists()) { + auto dirName = dbDir.dirName(); + + if (impl->m_CatalogueDao.addDB(defaultRepository, dirName)) { + impl->copyDBtoDB(dirName, impl->toWorkRepository(dirName)); + } + } + else { + qCInfo(LOG_CatalogueController()) << tr("Initialisation of Default repository detected") + << defaultRepository; + } } else { qCWarning(LOG_CatalogueController())