• If I run this code on a cleaned up Bangle watch, it seems to throw a file too big error eventually and the file size reported is ~ 1Mb. Am I doing something wrong to not be able to write on beyond 1Mb ?

    (** BEWARE: starts with Storage.eraseAll() ** )

    function repro() {
      var file = require("Storage").open("testfile.log", "a");
        while (true){
          var sentence = "Long string of gibberishLong string of gibberishLong string of gibberishLong string of gibberishLong string of gibberishLong string of gibberishLong string of gibberishLong string of gibberishLong string of gibberish\n";
        console.log("File size after write error: " + file.getLength());
        file = null;
    >Error: Error: File too big!
    File size after write error: 1036320

    Following are my env details

      VERSION: "2v04.375",
      GIT_COMMIT: "9b362663",
      FLASH: 524288, SPIFLASH: 4194304, STORAGE: 4194304, RAM: 65536,
      SERIAL: "a0cf0da6-7b6c234d",
      CONSOLE: "Bluetooth",
      MODULES: "Flash,Storage,hea" ... "le,graphical_menu",
      EXPTR: 536883676 }

    My fork was last synced with upstream on March 1, so I am wee bit behind. Apologies if this is causing the issue.

    Update: Just to clarify, I was expecting the File write to error out after ~4Mb which is the max capacity of the BangleJS.

  • Thr 2020.03.05

    Observation: L6 infinite while()

    Do I need to say more?

    L8 is most likely queued up multiple times before the first write occurs and is allowed to finish, cleaning up file I/O overhead. Maybe try a callback strategy, rather than relying on an error detection scheme?

  • This is as expected - it's as I'd mentioned in a previous thread - pages are ~4k, you have 255 pages because that's all you get with 1 char, so that's 1MB.

    You can now have 4 separate 1MB files, but the max file size for one StorageFile is 4MB.

    You can also allocate a massive (3.5MB maybe?) file using just Storage.write and then write to it yourself with your own method of figuring out where in the file you are.

  • Ah... silly me. I took long (ish) file names an indication of more than 255 pages being possible.

    I quite like the StorageFile api so I think I'll just build a rudimentary roll-over system where a new file is created on reaching max-size, until I've run out of all space available. Still hoping to never use all that space :-).

    Thanks again.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

StorageFile tops off at 1036320 (bits?) ~ 1Mb [Resolved]

Posted by Avatar for PiOfThings @PiOfThings