Picture of Lars Halkjær
Deleted asset listed in assets.json file
by Lars Halkjær - Tuesday, 26 November 2019, 2:19 PM
 

We have a problem with assets being listed more than once in the "asset.json" file.
This is a problem, as we have to use this list to map asset filenames from "real" filenames to the internal filename used by Adapt, when localising courses (typically mp3-files).

It seems that this is the scenario where it happens:

  • an mp3 asset is uploadet and inserted into a component.
  • a new version of the mp3 asset is loaded (as you cannot update an asset).
  • the new version is attached to the component.
  • the old mp3 asset is marked as deleted.

I looked in the database, where I found a "courseasset" record pointing to the deleted version, still linking it to the component.
I suppose this is what renders the entry in the "asset.json" file.

Could it be, that if you do he steps above in another order, this could happen?

Picture of Lars Halkjær
Re: Deleted asset listed in assets.json file
by Lars Halkjær - Tuesday, 26 November 2019, 3:10 PM
 

I stumbled upon a variation of the above:

An asset file is named "3_4c_2.mp3".

There are 4 uploads of this file, but the 3 first are marked as deleted.

The 4th one's "title" is changed to "3_4c2.mp3". (as this is the name we want in the "assets.json" file, to be consistent with other file names).

But on the next exportm the "title" in the "assets.json" file is still "3_4c_2.mp3"...

When I look in the database "assets" table the 4th one has a "title" of "3_4c2.mp3" - so this is not used for the export, even though this is the one used

Then I noticed something odd: All 4 versions have the same "filename" ("247c3dd4e6e9a9318aafb4645a780252bfb49734.mp3").

Could this be why the wrong "title" is selected (one of the deleted ones)?

As far as I remeber the "filename" is generated from the MD5 of the file.
If the file is the same for all uploads (it could happen - different people uploading the file anew) I would expect the file record to be updated, but it seems that the file (if this is the case) is overwritten and a new "assets" record is created.