ret = osl_add_row(table, objs);
if (ret < 0)
return ret;
- } else { /* get id of the dummy row and increment it */
+ } else {
+ /* check if name already exists */
struct osl_row *row;
- struct osl_object obj = {.data = "", .size = 1};
+ struct osl_object obj = {.data = name, .size = name_len};
+ ret = osl_get_row(table, BLOBCOL_NAME, &obj, &row);
+ if (ret < 0 && ret != -E_RB_KEY_NOT_FOUND)
+ return ret;
+ if (ret >= 0) { /* we already have a blob with this name */
+ obj.data = name + name_len;
+ obj.size = query->size - name_len;
+ return osl_update_object(table, row, BLOBCOL_DEF, &obj);
+ }
+ /* new blob, get id of the dummy row and increment it */
+ obj.data = "";
+ obj.size = 1;
ret = osl_get_row(table, BLOBCOL_NAME, &obj, &row);
if (ret < 0)
return ret;
int ret;
desc->dir = db;
ti->desc = desc;
- ret = osl_open_table(ti->desc, &ti->table);
- if (ret >= 0) {
- *table = ti->table;
+ ret = osl_open_table(ti->desc, table);
+ if (ret >= 0)
return ret;
- }
*table = NULL;
return ret == -E_NOENT? 1 : ret;
}