aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksi Lindeman <dec05eba@protonmail.com>2018-11-09 09:44:08 +0100
committerAleksi Lindeman <dec05eba@protonmail.com>2018-11-09 09:44:08 +0100
commit6d520dafec98bb4ebb7e40bd5110a5cbe5ebb47e (patch)
tree436181925c0dc064709737ff4bf4476e7a296385 /src
parent254fa05345462185c1c633a6c4b87a83cab68d28 (diff)
Append user to group if user already exists instead of throwing
Diffstat (limited to 'src')
-rw-r--r--src/DataView.cpp8
-rw-r--r--src/DatabaseStorage.cpp9
2 files changed, 15 insertions, 2 deletions
diff --git a/src/DataView.cpp b/src/DataView.cpp
index a5232f3..f94b2d8 100644
--- a/src/DataView.cpp
+++ b/src/DataView.cpp
@@ -1,5 +1,6 @@
#include "../include/odhtdb/DataView.hpp"
-#include <cstring>
+#include "../include/odhtdb/bin2hex.hpp"
+#include <string.h>
namespace odhtdb
{
@@ -12,4 +13,9 @@ namespace odhtdb
{
return !operator==(other);
}
+
+ std::string DataView::toString() const
+ {
+ return bin2hex((const char*)data, size);
+ }
}
diff --git a/src/DatabaseStorage.cpp b/src/DatabaseStorage.cpp
index 9611993..1d6f201 100644
--- a/src/DatabaseStorage.cpp
+++ b/src/DatabaseStorage.cpp
@@ -704,7 +704,14 @@ namespace odhtdb
rc = sqlite3_bind_blob(insertUserStmt, 2, userPublicKey.getData(), userPublicKey.getSize(), SQLITE_STATIC);
bindCheckError(rc);
- sqlite_step_throw_on_failure(sqliteDb, insertUserStmt, "insert data into NodeUser");
+ try
+ {
+ sqlite_step_throw_on_failure(sqliteDb, insertUserStmt, "insert data into NodeUser");
+ }
+ catch(DatabaseStorageAlreadyExists &e)
+ {
+ // User already exists in node, error can be ignored and instead we can continue to add user to group
+ }
addUserToGroup(nodeHash, userPublicKey, groupId);