charlesbaynham / OSFS

Overly Simplified File System for Arduino EEPROM
GNU General Public License v3.0
33 stars 9 forks source link

Improve overwriting files #6

Closed charlesbaynham closed 4 years ago

charlesbaynham commented 4 years ago

Changes from @dHutchings in PR #4:

Previously, if you tried to write a new file, while overwriting a previous one, it would return the FILE_ALREADY_EXISTS error if the filesizes weren't the same.

This doesn't make sense, espescially since the user explititly set the overwrite flag true.

This new behaviour returns FILE_ALREADY_EXISTS only if overwrite is false.

If overwrite is true and it encounters an identically named file, it either uses it (if the sizes are identical) or deletes it and moves on.

(cherry picked from commit f62b6cb050f94f5e71fc10d63834acd2827a75f0)

charlesbaynham commented 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:

charlesbaynham commented 4 years ago

@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?

dHutchings commented 4 years ago

@charlesbaynham tested changes (not that rigorously). Seems to work.

Platform was a teensy 3.2 microcontroller.

Thank you! This library is great.

charlesbaynham commented 4 years ago

Brilliant! Glad you like it