* @brief Force an immediate project snapshot with an optional caller-supplied label. */
| 851 | * @brief Force an immediate project snapshot with an optional caller-supplied label. |
| 852 | */ |
| 853 | API::CommandResponse API::Handlers::AssistantHandler::checkpoint(const QString& id, |
| 854 | const QJsonObject& params) |
| 855 | { |
| 856 | const auto label = params.value(QStringLiteral("label")).toString(); |
| 857 | const auto path = Misc::BackupManager::instance().snapshot(label); |
| 858 | if (path.isEmpty()) |
| 859 | return CommandResponse::makeError( |
| 860 | id, |
| 861 | ErrorCode::ExecutionError, |
| 862 | QStringLiteral("Failed to write checkpoint (BackupManager disabled, no project loaded, " |
| 863 | "or the backup directory is unwritable).")); |
| 864 | |
| 865 | QJsonObject result; |
| 866 | result[QStringLiteral("path")] = path; |
| 867 | result[QStringLiteral("label")] = label; |
| 868 | return CommandResponse::makeSuccess(id, result); |
| 869 | } |
| 870 | |
| 871 | /** |
| 872 | * @brief Resolve a checkpoint reference (path / timestamp / label) to an absolute path. |