func));
}
-static struct osl_row *find_hash_sister(unsigned char *hash)
+static int find_hash_sister(unsigned char *hash, struct osl_row **result)
{
- const struct osl_object obj = {.data = hash, .size = HASH_SIZE};
- struct osl_row *row;
+ int ret = aft_get_row_of_hash(hash, result);
- osl_get_row(audio_file_table, AFTCOL_HASH, &obj, &row);
- return row;
+ if (ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND))
+ return 0;
+ return ret;
+}
+
+static int find_path_brother(const char *path, struct osl_row **result)
+{
+ int ret = aft_get_row_of_path(path, result);
+
+ if (ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND))
+ return 0;
+ return ret;
}
/** The format of the data stored by save_audio_file_data(). */
objs[AFTCOL_PATH].size = strlen(path) + 1;
PARA_INFO_LOG("request to add %s\n", path);
- hs = find_hash_sister(hash);
- ret = aft_get_row_of_path(path, &pb);
- if (ret < 0 && ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND))
+ ret = find_hash_sister(hash, &hs);
+ if (ret < 0)
+ goto out;
+ ret = find_path_brother(path, &pb);
+ if (ret < 0)
goto out;
if (hs && pb && hs == pb && !(flags & ADD_FLAG_FORCE)) {
if (flags & ADD_FLAG_VERBOSE)
{
char *path = aca->query.data;
struct osl_row *path_brother;
- int ret = aft_get_row_of_path(path, &path_brother);
- if (ret < 0)
+ int ret = find_path_brother(path, &path_brother);
+ if (ret <= 0)
return ret;
return pass_buffer_as_shm(aca->fd, SBD_OUTPUT, (char *)&path_brother,
sizeof(path_brother));
{
unsigned char *hash = aca->query.data;
struct osl_row *hash_sister;
+ int ret = find_hash_sister(hash, &hash_sister);
- hash_sister = find_hash_sister(hash);
- if (!hash_sister)
- return 0;
+ if (ret <= 0)
+ return ret;
return pass_buffer_as_shm(aca->fd, SBD_OUTPUT, (char *)&hash_sister,
sizeof(hash_sister));
}