rename old addrbook to .bak and create a new one #109
This commit is contained in:
@@ -398,7 +398,16 @@ void AddressBook::readFromStorage()
|
||||
QList<QList<QString>> stuff;
|
||||
in >> stuff;
|
||||
|
||||
|
||||
//////////////found old addrbook, and rename it to .bak
|
||||
if (version != "v2")
|
||||
{
|
||||
auto filename = QStringLiteral("addresslabels.dat");
|
||||
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||
QFile address(dir.filePath(filename));
|
||||
|
||||
address.rename(dir.filePath("addresslabels.bak"));
|
||||
|
||||
}else{
|
||||
for (int i=0; i < stuff.size(); i++)
|
||||
{
|
||||
|
||||
@@ -406,6 +415,7 @@ void AddressBook::readFromStorage()
|
||||
|
||||
allLabels.push_back(contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// qDebug() << "Read " << version << " Hush contacts from disk...";
|
||||
@@ -448,7 +458,7 @@ void AddressBook::writeToStorage()
|
||||
c.push_back(item.getAvatar());
|
||||
contacts.push_back(c);
|
||||
}
|
||||
out << QString("v1") << contacts;
|
||||
out << QString("v2") << contacts;
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user