Class FileFingerprintCache


  • public class FileFingerprintCache
    extends java.lang.Object
    A best-effort cache of MD5 values of local files based on their {name,timestamp,length} fingerprint.

    Used to quickly verify that a local file hasn't changed.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String path, java.lang.String md5, long timestamp, long length)
      Add a file's fingerprint to the cache.
      void clear()
      Clears the cache.
      boolean contains​(java.lang.String path, java.lang.String md5, long timestamp, long length)
      Returns true if the specified file with the specified fingerprints (timestamp, length) was previously added to the cache with the specified md5.
      java.lang.String getMD5​(java.lang.String path, long timestamp, long length)
      Retrieves the md5 for the specified file that has the specified fingerprint (timestamp, length).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileFingerprintCache

        public FileFingerprintCache()
    • Method Detail

      • clear

        public void clear()
        Clears the cache.
      • add

        public void add​(java.lang.String path,
                        java.lang.String md5,
                        long timestamp,
                        long length)
        Add a file's fingerprint to the cache.
        Parameters:
        path - String path to the file
        md5 - hex-string md5 of the file
        timestamp - long last modified timestamp of the file
        length - long file size
      • contains

        public boolean contains​(java.lang.String path,
                                java.lang.String md5,
                                long timestamp,
                                long length)
        Returns true if the specified file with the specified fingerprints (timestamp, length) was previously added to the cache with the specified md5.
        Parameters:
        path - String path to the file
        md5 - hex-string md5 of the file
        timestamp - long last modified timestamp of the file
        length - long file size
        Returns:
        true if the fingerprint has previously been added to the cache.
      • getMD5

        public java.lang.String getMD5​(java.lang.String path,
                                       long timestamp,
                                       long length)
        Retrieves the md5 for the specified file that has the specified fingerprint (timestamp, length).
        Parameters:
        path - String path to the file
        timestamp - long last modified timestamp of the file
        length - long file size
        Returns:
        hex-string md5 or null if not present in the cache.