Jump to content

Database cleaning? via c#?


mickle026

Recommended Posts

mickle026

During the debug of a few errors in my plugins I have found that i have invalid data in my database ( because after excessive debugging this is what throws a null reference error )

Some people have an id & internal id, but no name or data
Some Movies have an id & internal id, but no name or data

They will probably be ones that were open or in the process of being added when the server crashed or my plugins crashed .

Apart from rebuilding the database from scratch is there a way to remove these, as vacuum appears to be leaving them behind?

I can see this, but unsure how it actaully works

var IndividualMovieId = libraryManager.GetItemById(SingleMovie);


libraryManager.DeleteItem(IndividualMovieId, new DeleteOptions
{
       DeleteFileLocation = false  
}, false);

I am thinking it will delete the table row from the database and if DeleteFileLocation is true delete the files from the disk or false then not delete them, then if {  },false not notify the parent.

So can I delete an row entry in the DB, leave the files incase they were added again but on another id.

But what does notify the parent actually do, or trigger?

I am asuming that I will get told by Luke that I shouldnt be doing this an allow a library scan to do it, but the problem is that these entries are stubbornly persistant and not being removed.  So some of the random crashes in plugins are caused by these entries when I try to get the Name.  The server it self doesnt seem to crash because of these but I want to fix them.

I would like to do this on the fly from one of my plugins if at all possible..

 

Link to comment
Share on other sites

That controls triggering the library events. I would just use the method overload that doesn't take that param.

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...