Closed charlesbaynham closed 4 years ago
In general, the way OSFS handles overwriting is a bit shaky at the moment. For example, we can end up with duplicate files on the filesystem (#5) and there's duplication of logic.
I think a bit of a refactor is in order. How about:
overwrite == false
, newFile
should use getFileInfo
to ensure that the file does not exist before writing it. overwrite == true
, newFile
should use deleteFile
to ensure that the file does not exist before writing it. newFile
should have the same conditions for overwrite == true or false
, we can remove all overwriting-related logic from the search loop: the normal check for fitting into a deleted file will work whether that file used to have the same name or not@dHutchings I've done the refactor I mentioned above: this code should now support adding larger / smaller files and it shouldn't create duplicates on the filesystem under any circumstances.
I haven't got access to a microcontroller (stuck at home...), would you mind trying these changes out and seeing if they work for your case?
@charlesbaynham tested changes (not that rigorously). Seems to work.
Platform was a teensy 3.2 microcontroller.
Thank you! This library is great.
Brilliant! Glad you like it
Changes from @dHutchings in PR #4:
(cherry picked from commit f62b6cb050f94f5e71fc10d63834acd2827a75f0)