remove file doesn"t free space

campestring
Posts: 17
Joined: Mon Dec 21, 2020 10:29 am

remove file doesn"t free space

Postby campestring » Fri May 14, 2021 12:50 pm

Hello, I am trying to delete a file with remove function. The file is successfully deleted but the free space of my storage doesn't change… Any ideas ?
Thanks

ESP_Minatel
Posts: 361
Joined: Mon Jan 04, 2021 2:06 pm

Re: remove file doesn"t free space

Postby ESP_Minatel » Fri May 14, 2021 1:23 pm

Hi,

Can you provide more information about? Can you share the code, IDF version, etc...?

We can try to help you if you provide us more details about it :D !

campestring
Posts: 17
Joined: Mon Dec 21, 2020 10:29 am

Re: remove file doesn"t free space

Postby campestring » Fri May 14, 2021 1:25 pm

here is the code where I delete the file :

int del = remove(g_day_stamp_comparaison);
if (!del)
{
ESP_LOGI(tag, "oldest file has been deleted sucessfully");
}

and here is where I check the free space :

static void storageModule_get_fatfs_usage(size_t *out_total_bytes, size_t *out_free_bytes)
{
FATFS *fs;
size_t free_clusters;
int res = f_getfree("0:", &free_clusters, &fs);
assert(res == FR_OK);
size_t total_sectors = (fs->n_fatent - 2) * fs->csize;
size_t free_sectors = free_clusters * fs->csize;

// assuming the total size is < 4GiB, should be true for SPI Flash
if (out_total_bytes != NULL)
{
*out_total_bytes = total_sectors * fs->ssize;
}
if (out_free_bytes != NULL)
{
*out_free_bytes = free_sectors * fs->ssize;
}
}

Who is online

Users browsing this forum: Google [Bot] and 119 guests