From 4021202e530c04eb7b971aa4cad4e8dbf50599b4 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 7 Mar 2025 15:27:46 -0500 Subject: [PATCH] Omit patch path from patch archive when saved. --- src/patch.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/patch.cpp b/src/patch.cpp index 3bbe90e7..428a185a 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -116,6 +116,13 @@ void Manager::save(std::string path) { INFO("Saving patch %s", path.c_str()); // Dispatch SaveEvent to modules APP->engine->prepareSave(); + + // Omit the patch path from the patch archive, so sharing their patch doesn't leak the user's home dir name, which is their OS username. + // Then restore it so it is saved to /autosave/patch.json on the next autosave. + std::string lastPath = this->path; + this->path = ""; + DEFER({this->path = lastPath;}); + // Save patch.json saveAutosave(); // Clean up autosave directory (e.g. removed modules) @@ -507,8 +514,6 @@ void Manager::fromJson(json_t* rootJ) { json_t* pathJ = json_object_get(rootJ, "path"); if (pathJ) path = json_string_value(pathJ); - else - path = ""; // unsaved json_t* unsavedJ = json_object_get(rootJ, "unsaved");