- status = lttng_destruction_handle_get_archive_location(handle, &location);
- if (status == LTTNG_DESTRUCTION_HANDLE_STATUS_OK) {
- ret = print_trace_archive_location(location, session->name);
- if (ret) {
- ERR("%sFailed to print the location of trace archive",
- newline_needed ? "\n" : "");
+ enum lttng_rotation_state rotation_state;
+ status = lttng_destruction_handle_get_rotation_state(destruction_handle.get(),
+ &rotation_state);
+ if (status != LTTNG_DESTRUCTION_HANDLE_STATUS_OK) {
+ ERR_FMT("{}Failed to query the rotation state from the destruction handle of session `{}`",
+ newline_needed ? "\n" : "",
+ session.name);
+ newline_needed = false;
+ } else {
+ switch (rotation_state) {
+ case LTTNG_ROTATION_STATE_NO_ROTATION:
+ break;
+ case LTTNG_ROTATION_STATE_COMPLETED:
+ {
+ const struct lttng_trace_archive_location *location;
+
+ status = lttng_destruction_handle_get_archive_location(
+ destruction_handle.get(), &location);
+ if (status == LTTNG_DESTRUCTION_HANDLE_STATUS_OK) {
+ ret = print_trace_archive_location(location, session.name);
+ if (ret) {
+ ERR_FMT("{}Failed to print the location of the latest trace archive of session `{}`",
+ newline_needed ? "\n" : "",
+ session.name);
+ newline_needed = false;
+ }
+
+ break;
+ }
+ }
+ /* fall-through. */
+ default:
+ ERR_FMT("{}Failed to get the location of the rotation performed during the destruction of `{}`",
+ newline_needed ? "\n" : "",
+ session.name);