check if recurring file exists

This commit is contained in:
DenioD
2020-07-05 20:15:32 +02:00
parent 460974f594
commit ab46276cee
2 changed files with 11 additions and 3 deletions

View File

@@ -319,7 +319,7 @@ QString Recurring::writeableFile() {
auto filename = QStringLiteral("recurringpayments.json");
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
if (!dir.exists())
if (dir.exists())
QDir().mkpath(dir.absolutePath());
if (Settings::getInstance()->isTestnet()) {
@@ -353,6 +353,9 @@ void Recurring::removeRecurringInfo(QString hash) {
void Recurring::readFromStorage() {
if (writeableFile().isEmpty())
{
QFile file(writeableFile());
file.open(QIODevice::ReadOnly);
@@ -365,10 +368,14 @@ void Recurring::readFromStorage() {
auto p = RecurringPaymentInfo::fromJson(k.toObject());
payments.insert(p.getHash(), p);
}
}else{}
}
void Recurring::writeToStorage() {
if (writeableFile().isEmpty())
{
QFile file(writeableFile());
file.open(QIODevice::ReadWrite | QIODevice::Truncate);
@@ -381,6 +388,7 @@ void Recurring::writeToStorage() {
out << QJsonDocument(arr).toJson();
file.close();
}else{}
}
/**