Skip to content

Commit

Permalink
Update FileDatabase.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ZikkeyLS committed Jun 4, 2024
1 parent b50c453 commit 0d6caf5
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ size_t FileDatabase::Upsert(const std::vector<MpChangeForm>& changeForms)
f << MpChangeForm::ToJson(changeForm).dump(2);
}

if (!f.is_open()) {
pImpl->logger->error("Unable to open file {}", filePath.string());
} else if (!f) {
pImpl->logger->error("Unknown error while writing file {}",
filePath.string());
} else {
++nUpserted;
}

if (!f.fail()) {
f.close();

Expand All @@ -43,15 +52,6 @@ size_t FileDatabase::Upsert(const std::vector<MpChangeForm>& changeForms)
errorCode.message());
}
}

if (!f.is_open()) {
pImpl->logger->error("Unable to open file {}", filePath.string());
} else if (!f) {
pImpl->logger->error("Unknown error while writing file {}",
filePath.string());
} else {
++nUpserted;
}
}

return nUpserted;
Expand Down

0 comments on commit 0d6caf5

Please sign in to comment.