reload a database, not refresh

Got an idea, post it here

reload a database, not refresh

Postby S Pittaway on Wed Jul 12, 2006 2:48 pm

Hi,


I have a plugin which saves the current state of the music database (using category:save to xml:music) and then parses it and adds new attributes to existing items in the music.xml file (in this case track ratings and played times).

To get these new attribs to show up in xlobby i have to do a music refresh, which rescans the music.xml file and then looks for any changes on the hard disks.

Because my music database is large (~10000 songs) and stored on a remote computer it takes a long time to search and check for changes.


It would be nice, if xlobby could do a "null" refresh - ie, rescan the xml file, but NOT search the hard disk for changes.

I think other people would find this feature usefull, has it gives a plugin a quick way of making lots of changes to a database.


Sean :)
Last edited by S Pittaway on Thu Jul 13, 2006 4:17 pm, edited 1 time in total.
S Pittaway
 
Posts: 651
Joined: Wed Jan 25, 2006 11:08 am
Location: Manchester, England

Postby badubo on Wed Jul 12, 2006 4:57 pm

it seems difficult to reload the database without refreshing it...

As you can change items in the dba (adding removing) and even folders, how do you want that xlobby can stay in the same level?
Also, in terms of .NET programmation, reloading a XML implies to recreate an object (nodes are changed).
badubo
 
Posts: 505
Joined: Mon May 03, 2004 7:33 pm
Location: Belgium

Postby S Pittaway on Wed Jul 12, 2006 5:06 pm

We already have an option to save the db to xml, so why not a option to re-load from xml?

I cant beleive its that hard to delete a db then re-call the startup load database code?


You dont have to wory about anything getting out of step, you simply - save, modify via a plugin, reload and nothing will have been lost.
S Pittaway
 
Posts: 651
Joined: Wed Jan 25, 2006 11:08 am
Location: Manchester, England

Postby badubo on Wed Jul 12, 2006 5:23 pm

saving to a dba is not the same : you make modifications in the loaded dba (in memory) and you dump it

But, modifying the source of a dba implies to reload it, "reload" means having a new instance of the dba (not the same) and forget the old one

The time needed for the "refresh" for a normal dba is mainly the time to reload it...

But what you probably want to do it to avoid the use of the template...
So, you only have to remove the reference of the used template when saving to the xml and the refresh will simply reload it.
But may be I don't correctly understand your problem
badubo
 
Posts: 505
Joined: Mon May 03, 2004 7:33 pm
Location: Belgium

Postby Stimpson J. Cat on Wed Jul 12, 2006 8:03 pm

I think what Pittaway means is that he would like a function which just reloads the database from the file, but does not scan the disk for changed files. I agree that this would be quite usefull. The option of simply not having a template referenced in the xml file is not optimal, because you may want to do normal refreshes as well. You just may not want to always do a full refresh.

For example, I could write a program which can be called from Xlobby (a normal executable) which modifies the xml file of a database. This avoids the hassle of having to make it a plugin (at the cost of the hassle of having to parse the xml myself). This program could then trigger an event in Xlobby (using a message) to make it refresh the database so that the changes are visible. But if the database in question has a lot of online files in it, this process could be quite slow. It would be better in cases like this to have an event which just reloads the database.

I have actually been thinking about writing such a function for handling movies. What I have in mind would store a couple of additional fields in the movies database which can be used to identify the CD or DVD the movie is on. Then I can automate the process of locating the movie you put into the drive in your database, and likewise have it automatically determine whether or not the movie is currently in the drive when you try to play it.

Unfortunately, I have no idea how to write an actual plugin. I am a C++ programmer, but I don't have any experience with .Net, and I don't use MS Visual Studio.

Anyway, consider the above a bump. I would like to have this feature too. And if anybody out there has any experience with writing Xlobby plugins in C++, please let me know.

Stimpy
Stimpson J. Cat
 
Posts: 7
Joined: Thu Jun 22, 2006 10:02 pm
Location: Aachen, Germany

Postby art on Wed Jul 12, 2006 9:11 pm

XL will reload db from the file (at least it does for me :) ) providing that you replace the file and not modify the original one. I have a Lin box with little Perl scrip that downloads new news clips from the web every night to the samba drive, deletes the old ones, and creates new db in xml file. In XL I have a simple plug-in that goes to the samba drive, checks if the xml file is newer than the local one, if yes it copies xml file to the local drive and tells XL to refresh that category. XL will reload it from the new file, however if I try to refresh category without overwriting xml file, XL will wipe it clean since I don't put any path or template reference inside of it. I guess the key is to create new file instead of making changes in existing.
I know it's not the same as having reload command, but it works for me :wink:
art
 
Posts: 284
Joined: Sat Mar 20, 2004 8:40 am
Location: Allen, TX

Postby dgemily on Wed Jul 12, 2006 9:43 pm

art, it's not a problem using on a database without template, but if you do it on a database with a template configuration xlobby will scan your files...
dgemily
 
Posts: 793
Joined: Thu May 13, 2004 6:24 am
Location: Paris, France

Postby art on Wed Jul 12, 2006 10:50 pm

dgemily wrote:art, it's not a problem using on a database without template, but if you do it on a database with a template configuration xlobby will scan your files...


dgemily,
I hate to argue with you as I have a great respect for your (and whole FR team) work :wink: , but I just tested it on my movie db, which has template and path etc., and everything works - key is to create a new file and not to modify existing. What I did was:
- I backed up my db
- started XL created button with command category>refresh; category name=movies
- created new file with just 1 movie and overwrote original file
- click button to refresh category
db was reloaded, not refreshed, showing only this one movie.
I did this few times with different movies, just to make sure, and it works.

Let me know if I'm missing anything here ...
art
 
Posts: 284
Joined: Sat Mar 20, 2004 8:40 am
Location: Allen, TX

Postby dalanik on Thu Jul 13, 2006 7:17 am

When I was writing Skype plugin, I had to update databases on several events (user status change). The first thing I tried was to

* create new database
* read records one by one from old into new and modify records that needed update
* when writing done, delete old, and rename new to old
* refresh

and it showed me empty database!

So in the end, I had to

* make a copy of old db
* read from copy of old and write into old
* refresh

and that seems to be working....

So IMHO, the thing is NOT to create new db while old still exists :-) but overwrite old DB...

D.
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Postby dgemily on Thu Jul 13, 2006 7:22 am

art wrote:
dgemily wrote:art, it's not a problem using on a database without template, but if you do it on a database with a template configuration xlobby will scan your files...


dgemily,
I hate to argue with you as I have a great respect for your (and whole FR team) work :wink:

:wink: no problem, I'm trying to understand what they want to do, so I'm not hating to argue with you :wink: and me too I have a great respect for you :wink:

art wrote:- I backed up my db
- started XL created button with command category>refresh; category name=movies
- created new file with just 1 movie and overwrote original file
- click button to refresh category
db was reloaded, not refreshed, showing only this one movie.
I did this few times with different movies, just to make sure, and it works.

ok, I understand what you mean, but I think (not sure) when you execute a command category:refresh on category using a database with template, xlobby do a litle scan on repertories configurated in the template, and if there is not file to add it will reload the xml, but if there are some, it will add items in database and reload the xml. ( you can chek this using the "basic" section of the set up for movies or musics)
so yep, if there is no file to add the refresh fonction will be quicker than if you create a full database (like when you delete the existing xml then do a scan).
but the "litle" scan can be not very quick if you have a lot of files, ( you can test it, first try to do a refresh on your music database then try to do the same refresh but delete the template before doing it...)

but anyway, that concerns only databases using a lot of files/items + template . so it's not a big deal.... and we can certainly disable the template fonction by a plugin ( as badubo said)

and yep, Stimpson J. Cat, it's a litle problem for you because you are not using a plugin.

hope it's make sense
Last edited by dgemily on Thu Jul 13, 2006 11:40 am, edited 1 time in total.
dgemily
 
Posts: 793
Joined: Thu May 13, 2004 6:24 am
Location: Paris, France

Postby S Pittaway on Thu Jul 13, 2006 7:37 am

I think that some of you are misunderstanding me, Stimpson J. Cat knows what i mean, not sure the rest of you do :)

All i want is the same as refresh, but DONT DO THE FILE SEARCH....

I spend all day writing code and i cant belevie its a big deal to NOT do an extra step?


badubo,

The time needed for the "refresh" for a normal dba is mainly the time to reload it...


Being honest, in my experiance thats bollocks :) my music database has ~10000 songs in it if i scan for new songs it takes ages to run... (this may be made worse by the files being stored on another pc?)

at the moment i can mofify the music xml file, save it, quit xlobby and restart xlobby in maybe a minute,

refreshing the music database, on the other hand, is somthing i always do last thing at night and leave it runing...




Anyway, its nice to start an active post for once :)
S Pittaway
 
Posts: 651
Joined: Wed Jan 25, 2006 11:08 am
Location: Manchester, England

Postby S Pittaway on Thu Jul 13, 2006 7:46 am

By the way, Stimpson J. Cat -

Download the free copy of c# and give the plugin a go...

C# is very easy to code and close enuff to C++ to let you dive striaght in and the actual interface to xlobby is very straightforward.

I have found that knocking up a plugin is normally the quickist way of getting xlobby to do what i want...


There are a few examples out there

All of the plugins i have wrote included the source code (admitadly, its shit, but its still there:)) and theres the xstats plugin source....

I wish more people would make there code available, its much easy to lift code and modify it to suit rather than starting from scratch...
S Pittaway
 
Posts: 651
Joined: Wed Jan 25, 2006 11:08 am
Location: Manchester, England

Postby art on Thu Jul 13, 2006 2:02 pm

S Pittaway wrote:I think that some of you are misunderstanding me, Stimpson J. Cat knows what i mean, not sure the rest of you do

All i want is the same as refresh, but DONT DO THE FILE SEARCH....


Let me rephrase your request to see if I understand it:
You would like to be able to change music.xml/movies.xml etc. file; save changes and have XL reload it WITHOUT re-scanning your HD for any changes in actual files (mp3, mpg, etc.). If that’s not it, then I am wasting my time typing it :) , but if it is, then it is possible.

dalanik wrote: So IMHO, the thing is NOT to create new db while old still exists but overwrite old DB...


There may be some timing issues with access, but I think we can agree that the point is to make XL think that it’s dealing with a new file.

On the coding side you can create a new file and overwrite the old one, or
you can modify existing, save it and change file attributes (created, modified, accessed), in the past I had to do it with EPG file to force XL to rebuild EPG…

dgemily wrote:ok, I understand what you mean, but I think (not sure) when you execute a command category:refresh on category using a database with template, xlobby do a litle scan on repertories configurated in the template, and if there is not file to add it will reload the xml, but if there are some, it will add items in database and reload the xml. ( you can chek this using the "basic" section of the set up for movies or musics)


Don’t use setup to refresh db (XL will re-scan your HD), use a button on the skin with category>refresh command and it won’t (or SendCommand from the plug-in).
In my example I have about 70 movies, and if I create small db with just one movie in it (including reference to the path to my movie folder and template name etc.) and overwrite existing one (the one with 70 movies) XL will not re-scan my HD for other 69, it will load my small new file and show only that one movie.

I’m probably not making myself clear again, but the above does work.

And by the way I would too like to see it as a separate command …. so bump :)
art
 
Posts: 284
Joined: Sat Mar 20, 2004 8:40 am
Location: Allen, TX

Postby dgemily on Thu Jul 13, 2006 3:47 pm

art wrote:Don’t use setup to refresh db (XL will re-scan your HD), use a button on the skin with category>refresh command and it won’t (or SendCommand from the plug-in).

I don't use a refresh from the set up, but I think is the same process that why I spoke aboute it ;)
art wrote:In my example I have about 70 movies, and if I create small db with just one movie in it (including reference to the path to my movie folder and template name etc.) and overwrite existing one (the one with 70 movies) XL will not re-scan my HD for other 69, it will load my small new file and show only that one movie.

I suppose you do it when xlobby is running... and yes I tried it, like start xlobby, then delete an item from my xml database and did a refresh ( by using an event) and yes my item is not here right now if I press another time on the refresh button, xlobby rescan my folder and import/add the item that I have deleted... ( of course for this test you don't have to use the dvdprofiler import ( original movies template) or xant plugin....)

just to confirm, add a file in your movies repertory, then press your refresh button.. you will see that xlobby scan your repertory and will import the new file... is it right ?

and I was speaking using it without plugin....
there is not a problem with 70 items, but if you have a big database, like for music, over than 10000 items it will make a litle time to reload your database....

but anyway we have the same conclusion, I was just insisted on the "template" without template there isn't problem
dgemily
 
Posts: 793
Joined: Thu May 13, 2004 6:24 am
Location: Paris, France

Postby S Pittaway on Thu Jul 13, 2006 4:16 pm

Sorry that my original request was a little woolly, but at At least everyone knows what i meant now :)

I have updated my original request and hope its easier to read -



I have a plugin which saves the current state of the music database (using category:save to xml:music) and then parses it and adds new attributes to existing items in the music.xml file (in this case track ratings and played times).

To get these new attribs to show up in xlobby i have to do a music refresh, which rescans the music.xml file and then looks for any changes on the hard disks.

Because my music database is large (~10000 songs) and stored on a remote computer it takes a long time to search and check for changes.


It would be nice, if xlobby could do a "null" refresh - ie, rescan the xml file, but NOT search the hard disk for changes.

I think other people would find this feature usefull, has it gives a plugin a quick way of making lots of changes to a database.


Sean :)
S Pittaway
 
Posts: 651
Joined: Wed Jan 25, 2006 11:08 am
Location: Manchester, England

Next