Package zeroinstall :: Package injector :: Module iface_cache :: Class IfaceCache
[frames] | no frames]

Class IfaceCache

source code

object --+
         |
        IfaceCache

The interface cache stores downloaded and verified interfaces in ~/.cache/0install.net/interfaces (by default).

There are methods to query the cache, add to it, check signatures, etc.

The cache is updated by fetch.Fetcher.

Confusingly, this class is really two caches combined: the in-memory cache of model.Interface objects, and an on-disk cache of model.ZeroInstallFeeds. It will probably be split into two in future.


See Also: iface_cache - the singleton IfaceCache instance.

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
bool
update_interface_if_trusted(self, interface, sigs, xml)
Update a cached interface (using update_interface_from_network) if we trust the signatures.
source code
 
update_interface_from_network(self, interface, new_xml, modified_time)
Update a cached interface.
source code
model.ZeroInstallFeed
get_feed(self, url)
Get a feed from the cache.
source code
model.Interface
get_interface(self, uri)
Get the interface for uri, creating a new one if required.
source code
[str]
list_all_interfaces(self)
List all interfaces in the cache.
source code
str
get_icon_path(self, iface)
Get the path of a cached icon for an interface.
source code
[gpg.Signature] or None
get_cached_signatures(self, uri)
Verify the cached interface using GPG.
source code
 
mark_as_checking(self, url)
Touch a 'last_check_attempt_timestamp' file for this feed.
source code
float | None
get_last_check_attempt(self, url)
Return the time of the most recent update attempt for a feed.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

update_interface_if_trusted(self, interface, sigs, xml)

source code 

Update a cached interface (using update_interface_from_network) if we trust the signatures. If we don't trust any of the signatures, do nothing.

Parameters:
Returns: bool
True if the interface was updated

update_interface_from_network(self, interface, new_xml, modified_time)

source code 

Update a cached interface. Called by update_interface_if_trusted if we trust this data. After a successful update, writer is used to update the interface's last_checked time.

Parameters:
  • interface (model.Interface) - the interface being updated
  • new_xml (str) - the downloaded replacement interface document
  • modified_time (long) - the timestamp of the oldest trusted signature (used as an approximation to the interface's modification time)
Raises:
  • SafeException - if modified_time is older than the currently cached time

get_feed(self, url)

source code 

Get a feed from the cache.

Parameters:
  • url - the URL of the feed
Returns: model.ZeroInstallFeed
the feed, or None if it isn't cached

get_interface(self, uri)

source code 

Get the interface for uri, creating a new one if required. New interfaces are initialised from the disk cache, but not from the network.

Parameters:
  • uri - the URI of the interface to find
Returns: model.Interface

get_icon_path(self, iface)

source code 

Get the path of a cached icon for an interface.

Parameters:
  • iface - interface whose icon we want
Returns: str
the path of the cached icon, or None if not cached.

get_cached_signatures(self, uri)

source code 

Verify the cached interface using GPG. Only new-style XML-signed interfaces retain their signatures in the cache.

Parameters:
  • uri (str) - the feed to check
Returns: [gpg.Signature] or None
a list of signatures, or None

Since: 0.25

mark_as_checking(self, url)

source code 

Touch a 'last_check_attempt_timestamp' file for this feed. If url is a local path, nothing happens. This prevents us from repeatedly trying to download a failing feed many times in a short period.

get_last_check_attempt(self, url)

source code 

Return the time of the most recent update attempt for a feed.

Returns: float | None
The time, or None if none is recorded

See Also: mark_as_checking