| 113 | |
| 114 | |
| 115 | void Manager::save(std::string path) { |
| 116 | INFO("Saving patch %s", path.c_str()); |
| 117 | // Dispatch SaveEvent to modules |
| 118 | APP->engine->prepareSave(); |
| 119 | |
| 120 | // 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. |
| 121 | // Then restore it so it is saved to <Rack user dir>/autosave/patch.json on the next autosave. |
| 122 | std::string lastPath = this->path; |
| 123 | this->path = ""; |
| 124 | DEFER({this->path = lastPath;}); |
| 125 | |
| 126 | // Save patch.json |
| 127 | saveAutosave(); |
| 128 | // Clean up autosave directory (e.g. removed modules) |
| 129 | cleanAutosave(); |
| 130 | |
| 131 | // Take screenshot (disabled because there is currently no way to quickly view them on any OS or website.) |
| 132 | // APP->window->screenshot(system::join(autosavePath, "screenshot.png")); |
| 133 | |
| 134 | double startTime = system::getTime(); |
| 135 | // Set compression level to 1 so that a 500MB/s SSD is almost bottlenecked |
| 136 | system::archiveDirectory(path, autosavePath, 1); |
| 137 | double endTime = system::getTime(); |
| 138 | INFO("Archived patch in %lf seconds", (endTime - startTime)); |
| 139 | } |
| 140 | |
| 141 | |
| 142 | void Manager::saveDialog() { |
nothing calls this directly
no test coverage detected