microbit-foundation / microbit-fs

A TypeScript library to manipulate the micro:bit MicroPython filesystem.
https://microbit-foundation.github.io/microbit-fs/
MIT License
12 stars 1 forks source link

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

Closed microbit-sam closed 5 years ago

microbit-sam commented 5 years ago

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
  3. Oops out of memory will appear
  4. Check microbitFs in console

Refresh, and with the same program

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

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

microbit-sam commented 5 years ago

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.');
        }
    }
microbit-carlos commented 5 years ago

Yes, this was indeed an issue due to the temporary code with magic numbers and fake chunk discovery. This has been fixed in https://github.com/microbit-foundation/microbit-fs/commit/310a71df1899b7a4fb8172e5dba19644933d9845.