core/collection: Move collection_update() out of the collection namespace
And bring collection_update_all() along with it. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
0cb16f5c64
commit
8a1f5403d0
|
@ -180,7 +180,7 @@ struct library *collection_add(const gchar *path)
|
|||
|
||||
library = library_find(path);
|
||||
if (library)
|
||||
collection :: update(library);
|
||||
collection_update(library);
|
||||
return library;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ void collection_remove(struct library *library)
|
|||
}
|
||||
}
|
||||
|
||||
void collection :: update(struct library *library)
|
||||
void collection_update(struct library *library)
|
||||
{
|
||||
struct scan_info *scan = new struct scan_info;
|
||||
scan->library = library;
|
||||
|
@ -205,12 +205,12 @@ void collection :: update(struct library *library)
|
|||
}
|
||||
}
|
||||
|
||||
void collection :: update_all()
|
||||
void collection_update_all()
|
||||
{
|
||||
struct db_entry *library, *next;
|
||||
|
||||
db_for_each(library, next, library_db_get())
|
||||
update(LIBRARY(library));
|
||||
collection_update(LIBRARY(library));
|
||||
}
|
||||
|
||||
void collection :: set_enabled(struct library *library, bool enabled)
|
||||
|
|
|
@ -130,13 +130,13 @@ static void on_add()
|
|||
|
||||
static void on_update()
|
||||
{
|
||||
collection :: update_all();
|
||||
collection_update_all();
|
||||
idle_enable();
|
||||
}
|
||||
|
||||
static void on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col)
|
||||
{
|
||||
collection :: update(get_library(path));
|
||||
collection_update(get_library(path));
|
||||
idle_enable();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,22 +26,6 @@ namespace collection
|
|||
|
||||
void save(struct queue *, enum queue_flags);
|
||||
|
||||
/**
|
||||
* First, scan over every Track in the database and remove
|
||||
* tracks that no longer exist in the filesystem.
|
||||
*
|
||||
* Next, scan over every file in the Library's root directory
|
||||
* and create new Track tags for every file found.
|
||||
*
|
||||
* @param library The library path that should be updated.
|
||||
*/
|
||||
void update(struct library *);
|
||||
|
||||
/**
|
||||
* Call library :: update() on all Library tags.
|
||||
*/
|
||||
void update_all();
|
||||
|
||||
/**
|
||||
* Use to enable or disable a library path. When a Library path
|
||||
* is disabled, its tracks will be removed from the Library queue.
|
||||
|
@ -72,4 +56,10 @@ struct library *collection_add(const gchar *);
|
|||
/* Called to remove a library directory from the collection manager. */
|
||||
void collection_remove(struct library *);
|
||||
|
||||
/* Called to update a library directory. */
|
||||
void collection_update(struct library *);
|
||||
|
||||
/* Called to update all library paths. */
|
||||
void collection_update_all();
|
||||
|
||||
#endif /* OCARINA_CORE_LIBRARY_H */
|
||||
|
|
|
@ -61,6 +61,59 @@ static void test_add()
|
|||
test_equal(queue_size(q), 48);
|
||||
}
|
||||
|
||||
static void test_update()
|
||||
{
|
||||
struct queue *q = collection :: get_queue();
|
||||
struct library *lib = library_get(0);
|
||||
|
||||
g_rename("tests/Music/Hyrule Symphony/", "tests/Music/symphony/");
|
||||
collection_update(lib);
|
||||
|
||||
/* Collection validation removes tests/Music/Hyrule Symphony/ */
|
||||
test_equal(idle_run_task(), true);
|
||||
test_equal(track_db_get()->db_size, 35);
|
||||
test_equal(lib->li_size, 35);
|
||||
test_equal(queue_size(q), 35);
|
||||
|
||||
/* tests/Music and tests/Music/Ocarina of Time/ have not changed */
|
||||
test_equal(idle_run_task(), true);
|
||||
test_equal(idle_run_task(), true);
|
||||
test_equal(track_db_get()->db_size, 35);
|
||||
test_equal(lib->li_size, 35);
|
||||
test_equal(queue_size(q), 35);
|
||||
|
||||
/* Scan tests/Music/symphony/ */
|
||||
test_equal(idle_run_task(), false);
|
||||
test_equal(track_db_get()->db_size, 48);
|
||||
test_equal(lib->li_size, 48);
|
||||
test_equal(queue_size(q), 48);
|
||||
|
||||
g_rename("tests/Music/symphony", "tests/Music/Hyrule Symphony/");
|
||||
collection_update_all();
|
||||
|
||||
/*
|
||||
* Collection validation removes tests/Music/symphony/,
|
||||
* and tests/Music has not changed
|
||||
*/
|
||||
test_equal(idle_run_task(), true);
|
||||
test_equal(idle_run_task(), true);
|
||||
test_equal(track_db_get()->db_size, 35);
|
||||
test_equal(lib->li_size, 35);
|
||||
test_equal(queue_size(q), 35);
|
||||
|
||||
/* tests/Music/Hyrule Symphony exists again */
|
||||
test_equal(idle_run_task(), true);
|
||||
test_equal(track_db_get()->db_size, 48);
|
||||
test_equal(lib->li_size, 48);
|
||||
test_equal(queue_size(q), 48);
|
||||
|
||||
/* tests/Music/Ocarina of Time/ has not changed */
|
||||
test_equal(idle_run_task(), false);
|
||||
test_equal(track_db_get()->db_size, 48);
|
||||
test_equal(lib->li_size, 48);
|
||||
test_equal(queue_size(q), 48);
|
||||
}
|
||||
|
||||
static void test_remove()
|
||||
{
|
||||
struct queue *q = collection :: get_queue();
|
||||
|
@ -74,7 +127,6 @@ static void test_remove()
|
|||
test_equal(queue_size(q), 0);
|
||||
}
|
||||
|
||||
|
||||
static void test_enable()
|
||||
{
|
||||
test_cp_data_dir();
|
||||
|
@ -104,35 +156,10 @@ static void test_enable()
|
|||
test_equal(queue_size(q), (unsigned)24);
|
||||
}
|
||||
|
||||
static void test_update()
|
||||
{
|
||||
queue *q = collection :: get_queue();
|
||||
test_rm_library_dirs();
|
||||
|
||||
collection :: update_all();
|
||||
test_equal(idle_run_task(), true);
|
||||
test_equal(queue_size(q), (unsigned)21);
|
||||
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
test_equal(idle_run_task(), (i < 3) ? true : false);
|
||||
test_equal(queue_size(q), (unsigned)21);
|
||||
|
||||
|
||||
test_generate_library();
|
||||
|
||||
collection :: update_all();
|
||||
test_equal(idle_run_task(), true);
|
||||
test_equal(queue_size(q), (unsigned)21);
|
||||
|
||||
for (unsigned int i = 0; i < 6; i++)
|
||||
test_equal(idle_run_task(), (i < 5) ? true : false);
|
||||
test_equal(queue_size(q), (unsigned)35);
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Collection Initialization", test_init),
|
||||
UNIT_TEST("Collection Add Path", test_add),
|
||||
UNIT_TEST("Collection Update Path", test_update),
|
||||
UNIT_TEST("Collection Remove Path", test_remove),
|
||||
UNIT_TEST("Library Enable and Disable", test_enable),
|
||||
UNIT_TEST("Library Update Path", test_update),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue