feat(lsm): remove data file when removing entry

lsm
Jef Roosens 2023-11-12 13:21:04 +01:00
parent c8728f2371
commit a4ad8c246e
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 20 additions and 1 deletions

View File

@ -147,5 +147,24 @@ lsm_error lsm_entry_disk_remove(lsm_entry_handle *handle) {
pthread_mutex_unlock(&store->idx.lock);
return res;
if (res != lsm_error_ok) {
return res;
}
// Remove data file if present
if (entry->data_len > 0) {
if (handle->f != NULL) {
fclose(handle->f);
handle->f = NULL;
}
char data_path[lsm_entry_data_path_len(handle) + 1];
lsm_entry_data_path(data_path, handle);
if (remove(data_path) != 0) {
return lsm_error_failed_io;
}
}
return lsm_error_ok;
}