library: Fix some bugs

- Check for path existing in the library already before adding again.
- Iterate over track database using <= for comparison, and not just <

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-01-22 19:36:23 -05:00 committed by Anna Schumaker
parent 078cb546f5
commit 0e2cc50e7b
1 changed files with 4 additions and 2 deletions

View File

@ -466,9 +466,9 @@ void library :: init()
library_db.load();
track_db.load();
for (i = track_db.first(); i <= track_db.last(); i = track_db.next(i))
for (i = track_db.first(); i < track_db.num_rows(); i = track_db.next(i))
get_callbacks()->on_library_track_add(i);
for (i = library_db.first(); i <= library_db.last(); i = library_db.next(i))
for (i = library_db.first(); i < library_db.num_rows(); i = library_db.next(i))
get_callbacks()->on_library_add(i, &library_db[i]);
}
@ -477,6 +477,8 @@ void library :: add_path(const std::string &dir)
unsigned int id;
if (g_file_test(dir.c_str(), G_FILE_TEST_IS_DIR) == false)
throw -E_INVAL;
if (library_db.has_key(dir))
return;
id = library_db.insert(library :: Library(dir, true));
library_db.save();