Gossamer Forum
Quote Reply
Plugin Version
What is the easiest way to find out (in the Install.pm file of a plugin) if the plugin is already installed, and if so, what version is installed?

Thanks for any help.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Plugin Version In reply to
Not sure if this is the best way but you could do something like:

Code:
my $config = do("$CFG->{admin_root_path}/Plugins/plugin.cfg");
my $version = $config->{Plugin_Name}->{version};

Last edited by:

Paul: Mar 23, 2002, 6:16 AM
Quote Reply
Re: [yogi] Plugin Version In reply to
Well, You'd want to really do what any "good" installation program would (before the days of windows) and check for each of the files you are suspect of. Start with the .cfg to see if the plugin is registered, if it's not registered, then even if it's installed, Links doesn't know about it, so you can (most likely) just install.

If you find it's registered, you should then check the .../admin/Plugins directory for the .pm file(s) you are looking for, and the templates directories for any installed files.

You'd want to perhaps do a check-sum of the files to see if they've been altered. The best way to do that, barring having access to all the previous files to run a diff, is to probably do your own "compare" based on non-space characters in the file. You'd only need to store the final result in an array in your installer to know if you got the "expected" or an unexpected result.

It depends on how complete you want to be, but I wouldn't suggest just using the the .cfg file, if you were worried about the version, since someone could have just copied a newer file over the old install -- or even modified their running copy.

If you want to just do a cursory check, check the .cfg file to see if it's registered, and then you can check the ../Plugins/Installed directory to extract the Install.pm file and check the version date on it. That's what Links does. That's the date that shows up on the "Installed" screen in the admin.

But, I would really suggest actually looking for the files you are going to replace, and checking them against a "known" checksum to see if they can be 'safely' replaced.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Plugin Version In reply to
Thanks to both of you for your answers.

Actually my question had not so much to do with the files, but with a database that belongs to a plugin. Let's say I install a table in version 1.0.0 of the plugin. At some point I decide that I need another field in the table (version 1.0.1). The install therefore has to check if it has to add the whole table (I don't want to use the force option, because that would delete any data in the table) or if it only has to add the new field.

I will use the information in the config file to get the version and then add the necessary tables/fields.

Ivan
-----
Iyengar Yoga Resources / GT Plugins