rename old addrbook to .bak and create a new one #109

This commit is contained in:
DenioD
2020-06-10 17:07:45 +02:00
parent 83912f6efb
commit 92e20e1c98

View File

@@ -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();
}