[jsword-devel] Getting the download size of modules

Don Parris evangelinux at matheteuo.org
Wed Sep 22 17:05:59 MST 2004


---------- Original Message -------------
Subject: [jsword-devel] Getting the download size of modules
Date: Wed, 22 Sep 2004 19:08:23 -0400
From: DM Smith <dmsmith555 at yahoo.com>
To: Java SWORD Developers Mailing List <jsword-devel at crosswire.org>


I did a test to get the download size of the zip file for a module.

The code is pretty simple:
    public int getSize(URL file)
    {
        try
        {
            URLConnection urlConnection = file.openConnection();
            int size = urlConnection.getContentLength();
            return size;
        }
        catch (IOException e)
        {
            return 0;
        }
    }

This works with http:// urls to the zipped modules, but it is general 
and should work for ftp:// and file:// as well.

I decided to test how long it would take to get all the "supported" 
(i.e. not locked and not gen book) modules.
It took 55 seconds to iterate over all of them.
I have broadband, so I imagine it will be significantly slower w/ dialup.

So I don't think this is a good technique. But it is better than 
getting, reading and parsing a directory listing.

Obviously we won't be able to do this in the foreground. But do we want 
to do it at all?

Or do we just want to let the user know the size in a confirmation 
dialog when they choose to do an install?

Any other ideas?
-----------------------

At least let the user know the file size in the confirmation dialogue.  Then, if they see it's a 10MB file, and they know they'll need the phone in the next 30 minutes, they won't be caught off guard.  I have always loathed sites that don't say how big a download is - especially if it's more than 1 or 2 MB.

-- 
DC Parris  GNU Evangelist
http://matheteuo.org/
evangelinux at matheteuo.org

Free software is like God's love - you can share it with anyone anywhere anytime!


More information about the jsword-devel mailing list