Algorithm for comparing manifest files.
- By Shawn Bedard
- June 13, 2000
/**
* This method assumes that the manifest from the server and client have already been received.
* This should be the case because if either file retrievals failed the logic above will not
* call this method. The two hashes below contain the file path & directory of the file to be
* downloaded in the key. The value stores the version number of the file indicated in the key.
* If the versions numbers differ between the server and client, the file will be downloaded.
* Also, files that do not exist on the client will be downloaded as well.
*/
public Vector compareManafestFiles()
{
Vector downList = new Vector(5);
Enumeration serverKeys = serverManifestHash.keys();
while ( serverKeys.hasMoreElements() )
{
String serverKey = (String)serverKeys.nextElement();
if (clientManifestHash.containsKey(serverKey) & fileExists(serverKey) )
{
// add to the download list if the values differ
if ( !((String)clientManifestHash.get(serverKey)).trim().equals(
((String)serverManifestHash.get(serverKey)).trim() )
{
downList.addElement(serverKey);
}
} else {
//if the key doesn't exist in the client OR the file does not exist
// add it to the download list
System.out.println("Client list does not contain key " + serverKey);
downList.addElement(serverKey);
}
}
// always download the manifest file if there are files
// to be downloaded.
if (downList.size() > 0)
downList.addElement(MANIFEST_VERSIONFILE);
return downList;
}