AAVSO / VStar

VStar is a visualisation and analysis tool for variable star data brought to you by AAVSO
https://www.aavso.org/vstar
GNU Affero General Public License v3.0
9 stars 3 forks source link

PluginManager cannot correctly check for local and remote plug-in equality #373

Closed mpyat2 closed 8 months ago

mpyat2 commented 9 months ago

It is supposed that PlugInManager enables the Update button for a particular plug-in only if the local and remote copies are non-equal. The problem is in getBytesFromURL() method: it was supposed that stream.available() returns the stream length. This is actually not the case: "Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream" (see the Java documentation).

It does work if the remote path is a local directory and sometimes works for Web (for instance for my test website http://mpta.atwebpages.com/vstar/plugins/ ; even for this site sometimes it returns 0) but does NOT work for www.aavso.org.

I'm sure we can fix the issue (it is not critical anyway, rather 'cosmetic'). But, @dbenn , do we really need to load the plug-ins from a remote location? Probably, for Linux users, it would be helpful. If yes, we could simplify PluginManages, leaving a single [Install/Update] button instead of the two ones. Anyway, we rely on the plug-in equality solely without checking what is newer.

dbenn commented 8 months ago

@mpyat2, does "do we really need to load the plug-ins from a remote location" relate to #192?

As you go on to say:

...we could simplify PluginManages, leaving a single [Install/Update] button instead of the two

We could just unconditionally install (and have one button) whether or not it's changed, as you say. At least I think that's what you're saying.

As an alternative, if we wanted to, we could do more than just rely on the length, always downloading all bytes and comparing against the local plugin. I need to look at the code again.