aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-11-09 09:44:08 +0100
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:46 +0200
commitd5614b905be6d76803330c182930fc6f0f12a7c2 (patch)
treeea69e119eb580b57a879baacd4c981c25c37dc0a /src
parent5f587967c4cbca02982d010c148947f19ff68e8e (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);