# Recovery

`RootRecovery`, accessed via `FMTCRoot.recovery`, allows access to the bulk download recovery system, which is designed to allow rescue (salvation and restarting) of failed downloads when they crashed due to an unexpected event.

{% embed url="<https://pub.dev/documentation/flutter_map_tile_caching/latest/flutter_map_tile_caching/RootRecovery-class.html>" %}

{% code fullWidth="false" %}

```dart
// List all recoverable regions, and whether each one has failed
await FMTCRoot.recovery.recoverableRegions; 
// List all failed downloads
await FMTCRoot.recovery.recoverableRegions.failedOnly; 
// Retrieve a specific recoverable region by ID
await FMTCRoot.recovery.getRecoverableRegion();
// Safely remove the specified recoverable region
await FMTCRoot.recovery.cancel(); 
```

{% endcode %}

## `RecoveredRegion`

`RecoveredRegion`s are wrappers containing recovery & some downloadable region information, around a `DownloadableRegion`.

Once a `RecoveredRegion` has been retreived, it contains the original `BaseRegion` in the `region` property.

To create a `DownloadableRegion` using the other available information with a provided `TileLayer`, use `toDownloadable`.

{% hint style="success" %}
A `RecoveredRegion` (and a `DownloadableRegion` generated from it) will point to only any remaining, un-downloaded tiles from the failed download.

The `start` tile will be adjusted from the original to reflect the progress of the download before it failed, meaning that tiles already successfully cached (excluding buffered) will not be downloaded again, saving time and network transfers.\
The `end` tile will be either the original, or the maximum number of tiles normally in the region (which will have no resulting difference than `null`, but allows for a quick estimate of the number of remaining tiles to be made without needing to re`check` the entire region).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fmtc.jaffaketchup.dev/usage/bulk-downloading/recovery.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
