library: Scan fixes

- Double check that track->valid == true before notifying the UI that
  there is a new track.
- Use primary_key() instead of manually calculating the full filepath.

Signed-off-by: Anna Schumaker <anna@ocarinaproject.net>
This commit is contained in:
Anna Schumaker 2014-04-08 08:13:22 -04:00
parent a470b88a46
commit ad1c3d6f9d
1 changed files with 5 additions and 1 deletions

View File

@ -281,6 +281,10 @@ static void read_tags(unsigned int lib_id, const std :: string &path)
genre_id = genre_db.insert(library :: AGInfo(library :: DB_GENRE, tag));
track_id = track_db.insert(library :: Track(tag, audio, lib_id,
artist_id, album_id, genre_id, path));
if (track_db.at(track_id)->valid == false)
return;
library_db.at(lib_id)->size++;
filter::add(artist_db.at(artist_id)->name, track_id);
@ -355,7 +359,7 @@ static void do_validate_library(unsigned int &lib_id)
if ((*it).library_id != lib_id)
continue;
path = library_db.at(lib_id)->root_path + "/" + (*it).filepath;
path = it->primary_key();
if (g_file_test(path.c_str(), G_FILE_TEST_EXISTS) == false) {
dprint("Removing file: %s\n", path.c_str());
track_db.remove(it - track_db.begin());