test: Add 1 and update 10 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 1m26s
Build-Test-Publish / build (linux/arm64) (push) Successful in 2m14s
Build-Test-Publish / create-manifest (push) Successful in 13s

This commit is contained in:
Your Name
2025-08-10 22:33:56 +12:00
parent 8ab6028597
commit 623879f67a
11 changed files with 140 additions and 108 deletions

View File

@@ -196,9 +196,9 @@ void PutHandler::handle_upload_object(const drogon::HttpRequestPtr& req, std::fu
// Ensure the temporary file is removed even if errors occur
ScopeFileDeleter temp_file_deleter(temp_path);
// Calculate hash
uint64_t hash = hash_file(temp_path.string());
if (hash == 0) {
// Calculate SHA-256 hash
std::string hash = hash_file(temp_path.string());
if (hash.empty()) {
resp->setStatusCode(drogon::k500InternalServerError);
nlohmann::json response = {{"result", "error"}, {"error", "Failed to calculate hash"}};
resp->setBody(response.dump());
@@ -215,8 +215,8 @@ void PutHandler::handle_upload_object(const drogon::HttpRequestPtr& req, std::fu
metadata["tgz_content_hash"] = get_hash_from_tgz(temp_path.string());
}
// Move file to final location
std::filesystem::path final_path = server_.config_.object_store_path / std::to_string(hash);
// Move file to final location (using SHA-256 hash as filename)
std::filesystem::path final_path = server_.config_.object_store_path / hash;
if (!std::filesystem::exists(final_path)) {
try {
@@ -235,7 +235,7 @@ void PutHandler::handle_upload_object(const drogon::HttpRequestPtr& req, std::fu
// Update database index
dbEntry entry;
entry.hash = std::to_string(hash);
entry.hash = hash;
entry.labeltags = metadata["labeltags"].get<std::vector<std::string>>();
entry.metadata = metadata;
@@ -250,7 +250,7 @@ void PutHandler::handle_upload_object(const drogon::HttpRequestPtr& req, std::fu
return;
}
resp->setBody(nlohmann::json({{"result", "success"}, {"hash", std::to_string(hash)}}).dump());
resp->setBody(nlohmann::json({{"result", "success"}, {"hash", hash}}).dump());
resp->setContentTypeCode(drogon::CT_APPLICATION_JSON);
callback(resp);
}