Page MenuHomePhabricator

No OneTemporary

diff --git a/services/backup/src/Tools.cpp b/services/backup/src/Tools.cpp
index fa469f166..afad647f5 100644
--- a/services/backup/src/Tools.cpp
+++ b/services/backup/src/Tools.cpp
@@ -1,23 +1,33 @@
#include "Tools.h"
+#include "GlobalTools.h"
+
#include <chrono>
#include <cstdlib>
#include <random>
namespace comm {
namespace network {
std::string generateRandomString(std::size_t length) {
const std::string CHARACTERS =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
thread_local std::random_device generator;
std::uniform_int_distribution<> distribution(0, CHARACTERS.size() - 1);
std::string random_string;
for (std::size_t i = 0; i < length; ++i) {
random_string += CHARACTERS[distribution(generator)];
}
return random_string;
}
+std::string generateHolder(
+ const std::string &blobHash,
+ const std::string &backupID,
+ const std::string &resourceID) {
+ return backupID + ID_SEPARATOR + resourceID + ID_SEPARATOR + blobHash +
+ ID_SEPARATOR + generateUUID();
+}
+
} // namespace network
} // namespace comm
diff --git a/services/backup/src/Tools.h b/services/backup/src/Tools.h
index 2fa862d1e..3c78aded6 100644
--- a/services/backup/src/Tools.h
+++ b/services/backup/src/Tools.h
@@ -1,11 +1,16 @@
#pragma once
#include <string>
namespace comm {
namespace network {
std::string generateRandomString(std::size_t length = 20);
+std::string generateHolder(
+ const std::string &blobHash,
+ const std::string &backupID,
+ const std::string &resourceID = "");
+
} // namespace network
} // namespace comm
diff --git a/services/lib/src/GlobalTools.h b/services/lib/src/GlobalTools.h
index 8cdf62f10..7b2ff3bec 100644
--- a/services/lib/src/GlobalTools.h
+++ b/services/lib/src/GlobalTools.h
@@ -1,20 +1,22 @@
#pragma once
#include <cstdint>
#include <string>
namespace comm {
namespace network {
+const std::string ID_SEPARATOR = ":";
+
uint64_t getCurrentTimestamp();
bool hasEnvFlag(const std::string &flag);
std::string decorateTableName(const std::string &baseName);
bool isDevMode();
std::string generateUUID();
} // namespace network
} // namespace comm

File Metadata

Mime Type
text/x-diff
Expires
Mon, Dec 23, 4:28 AM (17 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690352
Default Alt Text
(2 KB)

Event Timeline