diff options
-rw-r--r-- | include/odhtdb/DataView.hpp | 3 | ||||
-rw-r--r-- | src/DataView.cpp | 8 | ||||
-rw-r--r-- | src/DatabaseStorage.cpp | 9 |
3 files changed, 18 insertions, 2 deletions
diff --git a/include/odhtdb/DataView.hpp b/include/odhtdb/DataView.hpp index 2f22d83..b71b378 100644 --- a/include/odhtdb/DataView.hpp +++ b/include/odhtdb/DataView.hpp @@ -3,6 +3,7 @@ #include "types.hpp" #include "Hash.hpp" #include <unordered_map> +#include <string> namespace odhtdb { @@ -14,6 +15,8 @@ namespace odhtdb bool operator == (const DataView &other) const; bool operator != (const DataView &other) const; + std::string toString() const; + void *data; usize size; }; 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); |