MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / listCheckpoints

Method listCheckpoints

app/src/API/Handlers/AssistantHandler.cpp:956–979  ·  view source on GitHub ↗

* @brief Return the most recent N checkpoints for the current project. */

Source from the content-addressed store, hash-verified

954 * @brief Return the most recent N checkpoints for the current project.
955 */
956API::CommandResponse API::Handlers::AssistantHandler::listCheckpoints(const QString& id,
957 const QJsonObject& params)
958{
959 const int limit = params.value(QStringLiteral("limit")).toInt(20);
960 const auto rows = Misc::BackupManager::instance().list(limit);
961
962 QJsonArray arr;
963 for (const auto& v : rows) {
964 const auto row = v.toMap();
965 QJsonObject entry;
966 entry[QStringLiteral("path")] = row.value(QStringLiteral("path")).toString();
967 entry[QStringLiteral("timestamp")] = row.value(QStringLiteral("timestamp")).toString();
968 entry[QStringLiteral("sizeBytes")] =
969 static_cast<qint64>(row.value(QStringLiteral("sizeBytes")).toLongLong());
970 entry[QStringLiteral("label")] = row.value(QStringLiteral("label")).toString();
971 arr.append(entry);
972 }
973
974 QJsonObject result;
975 result[QStringLiteral("checkpoints")] = arr;
976 result[QStringLiteral("count")] = arr.size();
977 result[QStringLiteral("directory")] = Misc::BackupManager::instance().backupDirectory();
978 return CommandResponse::makeSuccess(id, result);
979}
980
981//--------------------------------------------------------------------------------------------------
982// Registration

Callers

nothing calls this directly

Calls 5

backupDirectoryMethod · 0.80
valueMethod · 0.45
listMethod · 0.45
appendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected