From 522343a193ccf9a86d901a12913334e196b6116a Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sun, 3 May 2026 16:04:22 +0800 Subject: [PATCH] make the uuid generation more robust --- src/slic3r/Utils/OrcaCloudServiceAgent.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp index f8a242f7ae..abbebef42c 100644 --- a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp +++ b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp @@ -74,19 +74,21 @@ constexpr const char* SECRET_STORE_SERVICE = "OrcaSlicer/Auth"; constexpr const char* SECRET_STORE_USER = "orca_refresh_token"; constexpr std::chrono::seconds TOKEN_REFRESH_SKEW{900}; // 15 minutes -std::string generate_uuid_for_setting_id(const std::string& name = "") +std::string generate_uuid_for_setting_id(const std::string& name, const std::string& user_id = "") { if (name.empty()) { return ""; } - // Use a fixed namespace UUID for OrcaSlicer profiles - // This ensures the same name always generates the same UUID + // Mix user_id into the hashed input so two different users generating a setting_id + // for an identically-named preset get distinct UUIDs. Without this, the cloud's ID + // space collides across accounts and the second user's create gets HTTP 409 with + // server_profile=null on every sync (the foreign owner's record is not exposed). static const boost::uuids::uuid orca_namespace = boost::uuids::string_generator()("f47ac10b-58cc-4372-a567-0e02b2c3d479"); boost::uuids::name_generator_sha1 gen(orca_namespace); - boost::uuids::uuid id = gen(name); + boost::uuids::uuid id = user_id.empty() ? gen(name) : gen(user_id + "/" + name); return boost::uuids::to_string(id); } @@ -904,7 +906,7 @@ int OrcaCloudServiceAgent::get_user_presets(std::map* values_map, unsigned int* http_code) { - std::string new_id = generate_uuid_for_setting_id(name); + std::string new_id = generate_uuid_for_setting_id(name, get_user_id()); if (new_id.empty()) { BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: request_setting_id failed - name is empty"; return "";