I think I misunderstood your question.
Using the checksum, it is possible to determine which image came from which repository. It's not possible to know if it was actually downloaded from there or already existed on the local machine in the assetcache
When you drag an image onto the map, the checksum is calculated and stored in a list. In addition, the image is stored in the assetcache
directory under the same name as the checksum. Whenever the token needs to be displayed, the checksum is retrieved from the token. This is then used as the asset name and the file in the assetcache
directory is opened and read into memory, stored in a BufferedImage
object. (I'm not 100% positive on some of this because it's Trevor tricky code!)
Since the repository is remote, I'm thinking that when the campaign is loaded, so are the index.gz
files from each repository URL. Those files have a list of checksums and relative pathnames on their server. Now when MapTool needs a particular image (i.e. checksum), it first searches in memory to see if the BufferedImage
object is already loaded. If not, it looks in the local assetcache
. Failing that, it looks through each of the index.gz
files one at a time. The first one that has the checksum in it identifies the URL to use and the filename relative to the index.gz
file on the server. That file is grabbed off the server and BufferedImage
is created to represent it. At the same time, it's stored in the local assetcache
so that the download can be avoided the next time the image is needed and there isn't a BufferedImage
for it. This might happen when you change maps -- all image data for the current map is thrown away and the assets from the new map are loaded.
As I said, this is a fairly tricky section of code because the images are also sent asynchronously over the network to other hosts on an as-needed basis. As Trevor posted recently, the long-standing "?" bug was a result of this section of code.