Puts a resource already on disk into the disk cache.

        Args:
            url: The original url of the resource
            path: The resource already available on disk

        Raises:
            CacheError: If the file cannot be put in cache

def put_path(self, url, path):
        """Puts a resource already on disk into the disk cache.

        Args:
            url: The original url of the resource
            path: The resource already available on disk

        Raises:
            CacheError: If the file cannot be put in cache
        """
        cache_path = self._url_to_path(url)

        # Ensure that cache directories exist
        try:
            dir = os.path.dirname(cache_path)
            os.makedirs(dir)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise Error('Failed to create cache directories for ' % cache_path)

        # Remove the resource already exist
        try:
            os.unlink(cache_path)
        except OSError:
            pass

        try:
            # First try hard link to avoid wasting disk space & overhead
            os.link(path, cache_path)
        except OSError:
            try:
                # Use file copy as fallaback
                shutil.copyfile(path, cache_path)
            except IOError:
                raise Error('Failed to cache %s as %s for %s' % (path, cache_path, url))