microbit-foundation / microbit-fs

A TypeScript library to manipulate the micro:bit MicroPython filesystem.

Home Page:https://microbit-foundation.github.io/microbit-fs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

After the filesystem runs out of space the filesystem doesn't appear to remove files correctly

microbit-sam opened this issue · comments

http://python-editor-parallax-filesystem-review.microbit.org.s3-eu-west-1.amazonaws.com/editor.html#

  1. Add a a large file to the filesystem
  2. Click download
  • This will append main.py to the filesystem
  1. Oops out of memory will appear
  2. Check microbitFs in console

Refresh, and with the same program

  1. Click download
  • This will append main.py to the filesystem
  1. This will download correctly
  2. Check microbitFs in console

For both the only file in files should be main.py

Is FS_NEXT_AVAILABLE_CHUNK not being reset when the oversized file is removed

https://github.com/microbit-foundation/js-microbit-micropython-fs/blob/74ab855a3746d092e4e5387525b76190e4019784/src/fs-builder.ts#L43

    var FS_START_CHUNK = 0x01;
    var FS_NEXT_AVAILABLE_CHUNK = FS_START_CHUNK;
    function fsIncreaseChunkIndex(numberOfChunks) {
        FS_NEXT_AVAILABLE_CHUNK += numberOfChunks;
        var unusedMap = new MemoryMap();
        // Check if we are over the filesystem area
        if (chuckIndexAddress(unusedMap, FS_NEXT_AVAILABLE_CHUNK) >=
            getEndAddress(unusedMap)) {
            throw new Error('There is no more space in the file system.');
        }
    }

Yes, this was indeed an issue due to the temporary code with magic numbers and fake chunk discovery.
This has been fixed in 310a71d.