If we could limit the scope to just image assets (i.e. JPG, PNG) and look at the following modulestore.definition block_type (i.e. html, problem) then that would suffice for now.
I’m trying to clean up MongoDB fs.chunk size by deleting unused assets in courses and thinking that performing these actions would reduce MongoDB storage and backup costs.
I don’t believe any command currently exists for this.
The newer Files and Uploads page (I think it’s on by default in Redwood–not sure when it became available) hits a REST endpoint in Studio that looks something like:
/assets/{course-key}/{asset-key}/usage
That eventually calls into the same module that you linked, into the _get_asset_usage_path function. That being said, it looks like there are unhandled edge cases because it traverses into Units but wouldn’t find things that are in standalone XBlocks (like static tabs that people sometimes use to hold syllabi), or top level things like the course thumbnail and cert-related assets.
But if I were creating a new management command to do this, that’s where I would start.
@dave
I was able to incorporate the endpoint that you mentioned to check asset usage and I’m seeing results. This helps a lot. Thank you.
I appreciate you informing me that this asset usage endpoint doesn’t currently check for edge cases like standalone XBlocks (i.e. static course tab), course thumbnail and cert-related usages. We definitely would need to consider adding a flag to exclude images like the course thumbnail from removal.
Shows where the iStock-508121319.jpg image is used in the course in multiple locations.