Browse Source

Omit patch path from patch archive when saved.

tags/v2.6.1
Andrew Belt 2 months ago
parent
commit
4021202e53
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      src/patch.cpp

+ 7
- 2
src/patch.cpp View File

@@ -116,6 +116,13 @@ void Manager::save(std::string path) {
INFO("Saving patch %s", path.c_str()); INFO("Saving patch %s", path.c_str());
// Dispatch SaveEvent to modules // Dispatch SaveEvent to modules
APP->engine->prepareSave(); 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 <Rack user dir>/autosave/patch.json on the next autosave.
std::string lastPath = this->path;
this->path = "";
DEFER({this->path = lastPath;});

// Save patch.json // Save patch.json
saveAutosave(); saveAutosave();
// Clean up autosave directory (e.g. removed modules) // 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"); json_t* pathJ = json_object_get(rootJ, "path");
if (pathJ) if (pathJ)
path = json_string_value(pathJ); path = json_string_value(pathJ);
else
path = "";


// unsaved // unsaved
json_t* unsavedJ = json_object_get(rootJ, "unsaved"); json_t* unsavedJ = json_object_get(rootJ, "unsaved");


Loading…
Cancel
Save