Truncate function presumes too few free pages #49

This commit is contained in:
Peter Andersson
2015-09-23 21:20:07 +02:00
parent 98b0357265
commit 16d0ae6d3a
+2 -1
View File
@@ -1402,7 +1402,8 @@ s32_t spiffs_object_truncate(
s32_t res = SPIFFS_OK;
spiffs *fs = fd->fs;
res = spiffs_gc_check(fs, remove ? 0 : SPIFFS_DATA_PAGE_SIZE(fs));
// need 2 pages if not removing: object index page + possibly chopped data page
res = spiffs_gc_check(fs, remove ? 0 : SPIFFS_DATA_PAGE_SIZE(fs) * 2);
SPIFFS_CHECK_RES(res);
spiffs_page_ix objix_pix = fd->objix_hdr_pix;