Skip to content
Snippets Groups Projects
Commit 08df7d47 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Sébastien Blin
Browse files

renaming: hardcode appdatalocal/ring/ path for windows and macos db

Change-Id: If6284ab0fdebd8a850fe4c6e7f9a8fc1cdc478f1
parent f7a54fae
No related branches found
No related tags found
No related merge requests found
......@@ -63,7 +63,7 @@ Database::Database()
{
// create data directory if not created yet
QDir dataDir;
dataDir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
dataDir.mkpath(getPath());
}
// initalize the database.
......@@ -71,7 +71,7 @@ Database::Database()
#ifdef ENABLE_TEST
db_.setDatabaseName(QDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)).filePath(NAME));
#else
db_.setDatabaseName(QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)).filePath(NAME));
db_.setDatabaseName(QDir(getPath()).filePath(NAME));
#endif
// open the database.
......@@ -96,6 +96,16 @@ Database::Database()
}
}
QString
Database::getPath()
{
#if defined(_WIN32) || defined(__APPLE__)
return QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).filePath("ring/");
#else
return QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#endif
}
Database::~Database()
{
......@@ -462,7 +472,7 @@ Database::migrateOldFiles()
void
Database::migrateLocalProfiles()
{
const QDir profilesDir = (QStandardPaths::writableLocation(QStandardPaths::DataLocation)) + "/profiles/";
const QDir profilesDir = getPath() + "/profiles/";
const QStringList entries = profilesDir.entryList({QStringLiteral("*.vcf")}, QDir::Files);
foreach (const QString& item , entries) {
auto filePath = profilesDir.path() + '/' + item;
......@@ -522,7 +532,7 @@ Database::migrateLocalProfiles()
void
Database::migratePeerProfiles()
{
const QDir profilesDir = (QStandardPaths::writableLocation(QStandardPaths::DataLocation)) + "/peer_profiles/";
const QDir profilesDir = getPath() + "/peer_profiles/";
const QStringList entries = profilesDir.entryList({QStringLiteral("*.vcf")}, QDir::Files);
......@@ -562,7 +572,7 @@ void
Database::migrateTextHistory()
{
// load all text recordings so we can recover CMs that are not in the call history
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/text/");
QDir dir(getPath() + "/text/");
if (dir.exists()) {
// get .json files, sorted by time, latest first
QStringList filters;
......
......@@ -227,6 +227,7 @@ public:
private:
void createTables();
QString getPath();
void storeVersion(const std::string& version);
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment