jigdo API

cachefile.hh File Reference

Cache with MD5 sums of file contents - used by JigdoCache in scan.hh. More...

#include <config.h>
#include <string>
#include <time.h>
#include <db.h>
#include <stdlib.h>
#include <string.h>
#include <debug.hh>
#include <status.hh>

Go to the source code of this file.


struct  DbError
 libdb errors More...
class  CacheFile
 Cache with MD5 sums of file contents. More...

Detailed Description

Cache with MD5 sums of file contents - used by JigdoCache in scan.hh.

The created libdb3 database contains one table with a mapping from filenames (without trailing zero byte) to a binary structure. The filename key is the second part of the complete filename, i.e. the part after any "//", as returned by FilePart::leafName(). The binary structure has the following format:

This is accessed and interpreted by CacheFile:

  Size Meaning
   4   lastAccess - timestamp of last read or write access to this data
   4   fileMtime - timestamp to detect modifications, and for entry expiry
   6   fileSize - for calculation of nr of blocks, and for entry expiry

This is not handled by CacheFile; it is passed as an opaque string of bytes to scan.hh classes:

   4   blockLength (of rsync sum)
   4   md5BlockLength
   4   blocks (number of valid md5 blocks in this entry)
   8   rsyncSum of file start (only valid if blocks > 0)
  16   fileMD5Sum (only valid if
                   blocks == (fileSize+md5BlockLength-1)/md5BlockLength )
  followed by n entries:
  16   md5sum of block of size md5BlockLength

Why is mtime and size not part of the key? Because we only want to store one entry per file, not an additional entry whenever the file is changed.

Generated on Tue Sep 23 14:27:42 2008 for jigdo by  doxygen 1.5.6