Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3117867
D3178.id9604.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D3178.id9604.diff
View Options
diff --git a/services/backup/docker-server/contents/server/src/DatabaseManager.h b/services/backup/docker-server/contents/server/src/DatabaseManager.h
--- a/services/backup/docker-server/contents/server/src/DatabaseManager.h
+++ b/services/backup/docker-server/contents/server/src/DatabaseManager.h
@@ -32,7 +32,7 @@
template <typename T>
std::shared_ptr<T>
innerFindItem(Aws::DynamoDB::Model::GetItemRequest &request);
- void innerRemoveItem(const Item &item, const std::string &key);
+ void innerRemoveItem(const Item &item, const PrimaryKeyValue primaryKeyValue);
public:
static DatabaseManager &getInstance();
diff --git a/services/backup/docker-server/contents/server/src/DatabaseManager.cpp b/services/backup/docker-server/contents/server/src/DatabaseManager.cpp
--- a/services/backup/docker-server/contents/server/src/DatabaseManager.cpp
+++ b/services/backup/docker-server/contents/server/src/DatabaseManager.cpp
@@ -30,12 +30,18 @@
void DatabaseManager::innerRemoveItem(
const Item &item,
- const std::string &key) {
+ const PrimaryKeyValue primaryKeyValue) {
Aws::DynamoDB::Model::DeleteItemRequest request;
request.SetTableName(item.getTableName());
+ PrimaryKey pk = item.getPrimaryKey();
request.AddKey(
- item.getPrimaryKey().partitionKey,
- Aws::DynamoDB::Model::AttributeValue(key));
+ pk.partitionKey,
+ Aws::DynamoDB::Model::AttributeValue(primaryKeyValue.partitionKey));
+ if (pk.sortKey != nullptr && primaryKeyValue.sortKey != nullptr) {
+ request.AddKey(
+ *pk.sortKey,
+ Aws::DynamoDB::Model::AttributeValue(*primaryKeyValue.sortKey));
+ }
const Aws::DynamoDB::Model::DeleteItemOutcome &outcome =
getDynamoDBClient()->DeleteItem(request);
@@ -99,20 +105,8 @@
}
void DatabaseManager::removeBackupItem(std::shared_ptr<BackupItem> item) {
- Aws::DynamoDB::Model::DeleteItemRequest request;
- request.SetTableName(item->getTableName());
- request.AddKey(
- BackupItem::FIELD_USER_ID,
- Aws::DynamoDB::Model::AttributeValue(item->getUserID()));
- request.AddKey(
- BackupItem::FIELD_CREATED,
- Aws::DynamoDB::Model::AttributeValue(std::to_string(item->getCreated())));
-
- const Aws::DynamoDB::Model::DeleteItemOutcome &outcome =
- comm::network::getDynamoDBClient()->DeleteItem(request);
- if (!outcome.IsSuccess()) {
- throw std::runtime_error(outcome.GetError().GetMessage());
- }
+ this->innerRemoveItem(
+ *item, PrimaryKeyValue(item->getUserID(), std::to_string(item->getCreated())));
}
void DatabaseManager::putLogItem(const LogItem &item) {
@@ -166,20 +160,8 @@
}
void DatabaseManager::removeLogItem(std::shared_ptr<LogItem> item) {
- Aws::DynamoDB::Model::DeleteItemRequest request;
- request.SetTableName(item->getTableName());
- request.AddKey(
- LogItem::FIELD_BACKUP_ID,
- Aws::DynamoDB::Model::AttributeValue(item->getBackupID()));
- request.AddKey(
- LogItem::FIELD_LOG_ID,
- Aws::DynamoDB::Model::AttributeValue(item->getLogID()));
-
- const Aws::DynamoDB::Model::DeleteItemOutcome &outcome =
- getDynamoDBClient()->DeleteItem(request);
- if (!outcome.IsSuccess()) {
- throw std::runtime_error(outcome.GetError().GetMessage());
- }
+ this->innerRemoveItem(
+ *item, PrimaryKeyValue(item->getBackupID(), item->getLogID()));
}
} // namespace database
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 1, 11:24 PM (21 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2403704
Default Alt Text
D3178.id9604.diff (3 KB)
Attached To
Mode
D3178: [services] Backup - Reuse remove logic
Attached
Detach File
Event Timeline
Log In to Comment