Remember that there's always a risk to lose resources when doing this. For example in the following case:
- You sync you data and the app downloads several resources
- Your network connection goes off
- Some of the notes associated with the resources didn't get downloaded
Now the resources in step 1 are "orphans" even though they have notes associated with them (and these notes will be downloaded on next sync). If you run any clean up script at this point, you will accidentally delete all these resources.