libsaria: Use find_item() for updating library paths
I need to check if the file is already in the library. I also made a note for how this check could be done faster using a tree. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
065feedee2
commit
28eaba41e0
|
@ -89,14 +89,9 @@ ScanTask::~ScanTask()
|
|||
{
|
||||
}
|
||||
|
||||
static bool new_file(string &file, list<libsaria::Track> &tracks)
|
||||
static bool check_file(libsaria::Track &track, void *data)
|
||||
{
|
||||
list<libsaria::Track>::iterator it;
|
||||
for (it = tracks.begin(); it != tracks.end(); it++) {
|
||||
if ((*it).get_filepath() == file)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return track.get_filepath() == *(string *)data;
|
||||
}
|
||||
|
||||
void ScanTask::run_task()
|
||||
|
@ -105,7 +100,13 @@ void ScanTask::run_task()
|
|||
list<libsaria::Track *> tracks;
|
||||
|
||||
for (it = file_list.begin(); it != file_list.end(); it++) {
|
||||
if (!new_file(*it, path->tracks))
|
||||
/*
|
||||
* TODO: What I really should do for this check is build up
|
||||
* a path component tree right before scanning, and then walk
|
||||
* the tree to check if the path exists. It'll be much faster
|
||||
* than having to walk the same list over and over...
|
||||
*/
|
||||
if (path->_tracks.find_item(check_file, &(*it)))
|
||||
continue;
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue