libsaria: Reduce library refreshes during update
The library only needs to refresh if new tracks were found, so don't do anything if nothing new has been added. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
6fd4d01e37
commit
8623779210
|
@ -26,7 +26,7 @@ namespace libsaria
|
|||
unsigned int get_size();
|
||||
void prepare_for_removal();
|
||||
void get_info(void (*)(struct libsaria::library::PathInfo &));
|
||||
void add_track(string &, sid_t &);
|
||||
bool add_track(string &, sid_t &);
|
||||
void validate_track(libsaria::Track *);
|
||||
void save(OutFile &);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <ocarina/gtk.h>
|
||||
|
||||
GtkWidget *get_header();
|
||||
void put_header();
|
||||
void header_init();
|
||||
|
||||
bool entry_focused();
|
||||
|
||||
|
|
|
@ -54,23 +54,27 @@ void ScanTask::run_task()
|
|||
{
|
||||
list<pair<string, sid_t> >::iterator it;
|
||||
SaveTask *save;
|
||||
bool dirty = false;
|
||||
|
||||
for (it = files.begin(); it != files.end(); it++) {
|
||||
try {
|
||||
lib_path->add_track(it->first, it->second);
|
||||
if (lib_path->add_track(it->first, it->second))
|
||||
dirty = true;
|
||||
} catch (string message) {
|
||||
println(message);
|
||||
}
|
||||
}
|
||||
|
||||
/* Save the library */
|
||||
save = new SaveTask(libsaria::library::save);
|
||||
save->queue_front();
|
||||
if (dirty) {
|
||||
/* Save the library */
|
||||
save = new SaveTask(libsaria::library::save);
|
||||
save->queue_front();
|
||||
|
||||
/* Bookkeeping for the UI */
|
||||
libsaria::library::sort_list();
|
||||
libsaria::index::refresh();
|
||||
libsaria::library::refresh();
|
||||
/* Bookkeeping for the UI */
|
||||
libsaria::library::sort_list();
|
||||
libsaria::index::refresh();
|
||||
libsaria::library::refresh();
|
||||
}
|
||||
}
|
||||
|
||||
static inline ScanTask *scan_entry(struct dirent *dirp,
|
||||
|
@ -129,13 +133,15 @@ void ReaddirTask::run_task()
|
|||
namespace libsaria
|
||||
{
|
||||
|
||||
void LibraryPath::add_track(string &filepath, sid_t &songid)
|
||||
bool LibraryPath::add_track(string &filepath, sid_t &songid)
|
||||
{
|
||||
libsaria::Track *track;
|
||||
if (has_id(songid) == false) {
|
||||
track = new libsaria::Track(filepath, songid);
|
||||
file_list.push_back(track);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LibraryPath::update()
|
||||
|
|
Loading…
Reference in New Issue