Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Database refreshing/pruning (Read 3080 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Database refreshing/pruning

I was looking into mimicking the effects of preferences->Database->Remove Dead Entries and preferences->Database->Scan, but I wanted to see if I am thinking about this correctly...

Does playlist_oper::process_locations add files to the database if they are not there already?  is metadb::user_requested_remove the way to go to remove dead entries?

Here's the functions as I envision them:

Code: [Select]
void database_scan_music_directory()
{
    string8 music_path = g_music_directory;
    ptr_list_t<const char> file_list;
    metadb_handle_list handles;
    file_list.add_item(music_path);
    playlist_oper::get()->process_locations(file_list, handles);
    handles.delete_all();
}


Code: [Select]
void database_prune_dead_entries()
{
    metadb_handle_list handles;
    metadb::get()->database_lock();
    metadb::get()->get_all_entries(handles);

    for (int i=0;i<handles.get_count();i++)
    {
 const playable_location *play = handles[i]->handle_get_location();
 if (input::is_entry_dead(play))
 {
     metadb::get()->user_requested_remove(play);
 }
    }
    handles.delete_all();
    metadb::get()->database_unlock();
}


Thanks
There used to be a link to my website here.

Database refreshing/pruning

Reply #1
Quote
Does playlist_oper::process_locations add files to the database if they are not there already?[a href="index.php?act=findpost&pid=276679"][{POST_SNAPBACK}][/a]
Yes.
Quote
is metadb::user_requested_remove the way to go to remove dead entries?[a href="index.php?act=findpost&pid=276679"][{POST_SNAPBACK}][/a]
No, it is intented to remove live entries that the user explicitly requested to be removed. Use one of the following metadb methods to remove dead files from the database:
Code: [Select]
    virtual void file_removed(const char * src)=0;//use this to tell database that url [src] is dead
   virtual void entry_dead(const playable_location * entry)=0;//same as file_removed but taking playable_location

Database refreshing/pruning

Reply #2
Thanks... appreciate it...
There used to be a link to my website here.