# When are media files re-downloaded?

**URL:** <https://forum.getodk.org/t/when-are-media-files-re-downloaded/36900>\
**Category:** Support\
**Tags:** odk-collect\
**Created:** [February 8, 2022, 4:18am UTC](https://forum.getodk.org/t/when-are-media-files-re-downloaded/36900 "2022-02-08T04:18:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahblake](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ahblake/32/22392_2.png) [@ahblake](https://forum.getodk.org/u/ahblake)\
**Post date:** [February 8, 2022, 4:18am UTC](https://forum.getodk.org/t/when-are-media-files-re-downloaded/36900/1 "2022-02-08T04:18:18Z")

</div>

Without wishing to derail this thread further, this does relate to a question I have on media and how/when they are updated.

- If a form definition is updated do all media (CSV/image etc) also get redownloaded to device?
- If any supporting media are updated without a form definition, update are they not updated on device?
- I feel like I've seen reference to this elsewhere, but is there also a plan to include tilesets in media so they don't have to be sideloaded.

> [@Ability to load locations into the geowidget to guide data collection](https://forum.getodk.org/t/ability-to-load-locations-into-the-geowidget-to-guide-data-collection/27406/18):
>
> Out of the topic but do you mean another way to update media on phones than publishing a whole new version ?

> [@Ability to load locations into the geowidget to guide data collection](https://forum.getodk.org/t/ability-to-load-locations-into-the-geowidget-to-guide-data-collection/27406/20):
>
> Yes, the idea with an entity-based model is that entities would be synced between Collect and the server outside of the context of a single form. So you could have 10k entities and if only one changes, only that one would be updated.

If media were downloaded initially and then only when updated they were redownloaded, this would be very helpful for sync speeds, I have been loading hundreds to thousands [\*] of media and would like to use frequently updated CSV reference files also.

[\*] in this case I didn't upload to Central, rather I sideloaded ~1gb / 6000x images over USB and upon definition update I renamed the folder version # so the latest definition had a path to the media)

Lastly, to bring it back on topic, being able to load and display and select locations/items in the `placement-map` appearance would be incredible!

---

<div class="post-metadata">

**Author:** ![seadowg](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/seadowg/32/10045_2.png) [@seadowg](https://forum.getodk.org/u/seadowg)\
**Post date:** [February 8, 2022, 10:15am UTC](https://forum.getodk.org/t/when-are-media-files-re-downloaded/36900/2 "2022-02-08T10:15:16Z")

</div>

> [@ahblake](#):
>
> - If a form definition is updated do all media (CSV/image etc) also get redownloaded to device?
> - If any supporting media are updated without a form definition, update are they not updated on device?

> [@ahblake](#):
>
> If media were downloaded initially and then only when updated they were redownloaded, this would be very helpful for sync speeds, I have been loading hundreds to thousands [\*] of media and would like to use frequently updated CSV reference files also.

Collect treats forms as "updated" if the form definition or the media files are different on the server than they are on the device. It won't redownload media files it's already got on the device however as it compares the hashes of local files with the hash the server returns for the media files and will skip files it already has. This optimization requires the server you're using to implement the [Open Rosa spec](https://docs.getodk.org/openrosa/) correctly of course - Central does this, but a custom server might not. If you're using "Exactly Match Server" for form management, this should all be happening in the background.

In your use case, Collect should only redownload the updated CSV (and the form definition assuming you're changing the form version each time).

> [@ahblake](#):
>
> I feel like I've seen reference to this elsewhere, but is there also a plan to include tilesets in media so they don't have to be sideloaded.

It's definitely been discussed before but it's not something the core team is currently working on.

---

<div class="post-metadata">

**Author:** ![ahblake](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ahblake/32/22392_2.png) [@ahblake](https://forum.getodk.org/u/ahblake)\
**Post date:** [February 8, 2022, 10:28am UTC](https://forum.getodk.org/t/when-are-media-files-re-downloaded/36900/3 "2022-02-08T10:28:01Z")

</div>

> [@seadowg](#):
>
> It won't redownload media files it's already got on the device however as it compares the hashes of local files with the hash the server returns for the media files and will skip files it already has.

Thanks for the confirmation, I expected something like this, but the time for a definition update is often so long I thought perhaps it was replacing everything.

I won't derail this thread any further and will ask elsewhere if needed.

---

<div class="post-metadata">

**Author:** ![seadowg](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/seadowg/32/10045_2.png) [@seadowg](https://forum.getodk.org/u/seadowg)\
**Post date:** [February 11, 2022, 11:59am UTC](https://forum.getodk.org/t/when-are-media-files-re-downloaded/36900/4 "2022-02-11T11:59:36Z")

</div>

> [@seadowg](#):
>
> Collect treats forms as "updated" if the form definition or the media files are different on the server than they are on the device. It won't redownload media files it's already got on the device however as it compares the hashes of local files with the hash the server returns for the media files and will skip files it already has.

@ahblake I've realized that I got my cases confused here: if the form version changes Collect doesn't check for matching hashes and simply downloads all media files into a new directory. I'd been thinking about the case where form version does not change but the media files do (a new one is added for example) - this case isn't actually possible with Central, but Collect does deal with it. We're going to work out if we can change the behaviour so that media files don't get redownloaded (for updates) without causing any problems.

---

<div class="post-metadata">

**Author:** ![ahblake](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ahblake/32/22392_2.png) [@ahblake](https://forum.getodk.org/u/ahblake)\
**Post date:** [February 11, 2022, 11:11pm UTC](https://forum.getodk.org/t/when-are-media-files-re-downloaded/36900/5 "2022-02-11T23:11:22Z")

</div>

Aha, that clears it up and explains why definition updates take as long as the initial form add.

I have some image heavy forms that will have frequent definition updates, not redownloading and duplicating in definition version folders would be great for update speed and device storage.

---

<div class="post-metadata">

**Author:** ![LN](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ln/32/1605_2.png) [@LN](https://forum.getodk.org/u/LN)\
**Post date:** [March 2, 2022, 10:51pm UTC](https://forum.getodk.org/t/when-are-media-files-re-downloaded/36900/6 "2022-03-02T22:51:41Z")

</div>

I've split out this thread about media re-downloads because it stands on its own. @seadowg has made the update he described so that existing media files aren't re-downloaded. We should have a beta for that within the next 24 hours.

---

<div class="post-metadata">

**Author:** ![ahblake](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ahblake/32/22392_2.png) [@ahblake](https://forum.getodk.org/u/ahblake)\
**Post date:** [March 16, 2022, 12:19am UTC](https://forum.getodk.org/t/when-are-media-files-re-downloaded/36900/7 "2022-03-16T00:19:26Z")

</div>

I'll test this shortly, fantastic!
