store project settings content when opening database
This is required to tell Sourcetrail that the database content is up to date with the current project settings.
This commit is contained in:
@@ -51,6 +51,8 @@ namespace sourcetrail
|
||||
void setupDatabase();
|
||||
void clearDatabase();
|
||||
|
||||
void setProjectSettingsText(const std::string& text);
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isCompatible() const;
|
||||
int getLoadedDatabaseVersion() const;
|
||||
|
||||
@@ -94,6 +94,7 @@ namespace sourcetrail
|
||||
void setupDatabaseTables();
|
||||
void clearDatabaseTables();
|
||||
void createOrResetProjectFile();
|
||||
void updateProjectSettingsText();
|
||||
int addNodeHierarchy(const NameHierarchy& nameHierarchy);
|
||||
int addFile(const std::string& filePath);
|
||||
int addEdge(int sourceId, int targetId, EdgeKind edgeKind);
|
||||
|
||||
@@ -86,6 +86,11 @@ namespace sourcetrail
|
||||
setupDatabase();
|
||||
}
|
||||
|
||||
void DatabaseStorage::setProjectSettingsText(const std::string& text)
|
||||
{
|
||||
insertOrUpdateMetaValue("project_settings", text);
|
||||
}
|
||||
|
||||
bool DatabaseStorage::isEmpty() const
|
||||
{
|
||||
const std::string tableName = "meta";
|
||||
|
||||
@@ -81,26 +81,6 @@ namespace sourcetrail
|
||||
}
|
||||
m_projectFilePath += ".srctrlprj";
|
||||
|
||||
try
|
||||
{
|
||||
openDatabase();
|
||||
}
|
||||
catch (const SourcetrailException e)
|
||||
{
|
||||
m_lastError = e.getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
setupDatabaseTables();
|
||||
}
|
||||
catch (const SourcetrailException e)
|
||||
{
|
||||
m_lastError = e.getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
bool projectFileExists = false;
|
||||
{
|
||||
@@ -122,6 +102,27 @@ namespace sourcetrail
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
openDatabase();
|
||||
}
|
||||
catch (const SourcetrailException e)
|
||||
{
|
||||
m_lastError = e.getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
setupDatabaseTables();
|
||||
updateProjectSettingsText();
|
||||
}
|
||||
catch (const SourcetrailException e)
|
||||
{
|
||||
m_lastError = e.getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -145,16 +146,7 @@ namespace sourcetrail
|
||||
try
|
||||
{
|
||||
clearDatabaseTables();
|
||||
}
|
||||
catch (const SourcetrailException e)
|
||||
{
|
||||
m_lastError = e.getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
createOrResetProjectFile();
|
||||
updateProjectSettingsText();
|
||||
}
|
||||
catch (const SourcetrailException e)
|
||||
{
|
||||
@@ -661,6 +653,33 @@ namespace sourcetrail
|
||||
}
|
||||
}
|
||||
|
||||
void SourcetrailDBWriter::updateProjectSettingsText()
|
||||
{
|
||||
try
|
||||
{
|
||||
std::ifstream f(m_projectFilePath.c_str());
|
||||
if (f.is_open())
|
||||
{
|
||||
std::string line;
|
||||
std::string text;
|
||||
while (getline(f, line))
|
||||
{
|
||||
text += line + '\n';
|
||||
}
|
||||
f.close();
|
||||
m_storage->setProjectSettingsText(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw SourcetrailException("Unable to open project file.");
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw SourcetrailException("Exception occurred while creating project file.");
|
||||
}
|
||||
}
|
||||
|
||||
int SourcetrailDBWriter::addNodeHierarchy(const NameHierarchy& nameHierarchy)
|
||||
{
|
||||
if (nameHierarchy.nameElements.size() == 0)
|
||||
|
||||
Reference in New Issue
Block a user