Deleting persistent asset files from old firmware builds (Asset OTA)?

Hi, I've been messing around with Asset OTA, and can't figure out how to clear out old assets.

I used the example firmware, but dragged files in and out on various compiles just to test. The old files are not showing up at all in console, but ARE still showing up as "found assets" in the print out from the checkAssets() function. How do I get rid of the old files?

I tried disconnecting the power, EEPROM.clear(); in the setup, and fsync(fd); after the open and none worked so I'm out of ideas. Any thoughts?

Thanks.

The checkAssets() function in the example code stores a copy of the assets in the assetsDir. I would change the code to be something like this:


void checkAssets()
{
    // This is just for demonstration purposes for reading assets
    DIR *dirp = opendir(assetsDir);
    if (dirp)
    {
        while (true)
        {
            struct dirent *de = readdir(dirp);
            if (!de)
            {
                break;
            }
            if (de->d_type != DT_REG)
            {
                // Not a file
                continue;
            }
            String path = String::format("%s/%s", assetsDir, de->d_name);
            unlink(path);
        }
    }
}

Once it runs once, it will delete the files from the file system.

1 Like

Ah unlink! Thank you Rick, that worked perfectly.

I added a section to the docs about cleaning up from the file asset example.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.