mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Add purpose section and comments to interposition/updater.py
This commit is contained in:
parent
0cda6d3d22
commit
98acdb8bc0
1 changed files with 16 additions and 21 deletions
|
|
@ -113,7 +113,7 @@
|
|||
# We import them directly into our namespace so that there is no name conflict.
|
||||
from configuration import Configuration, InvalidConfiguration
|
||||
from utility import Logger, InterpositionException
|
||||
#TODO: Remove utility because the Logger is it two places.
|
||||
#TODO: Remove utility because the Logger is at two places.
|
||||
|
||||
|
||||
|
||||
|
|
@ -197,23 +197,6 @@ def download_target(self, target_filepath):
|
|||
return destination_directory, filename
|
||||
|
||||
|
||||
# TODO: decide prudent course of action in case of failure
|
||||
def get_target_filepath(self, source_url):
|
||||
# Locate the fileinfo of 'target_filepath'. updater.target() searches
|
||||
# Targets metadata in order of trust, according to the currently trusted
|
||||
# snapshot. To prevent consecutive target file requests from referring to
|
||||
# different snapshots, top-level metadata is not automatically refreshed.
|
||||
targets = [self.updater.target(target_filepath)]
|
||||
|
||||
# TODO: targets are always updated if destination directory is new, right?
|
||||
updated_targets = self.updater.updated_targets(targets, destination_directory)
|
||||
|
||||
for updated_target in updated_targets:
|
||||
self.updater.download_target(updated_target, destination_directory)
|
||||
|
||||
return destination_directory, filename
|
||||
|
||||
|
||||
# TODO: decide prudent course of action in case of failure
|
||||
def get_target_filepath(self, source_url):
|
||||
"""Given source->target map, figure out what TUF *should* download given a
|
||||
|
|
@ -383,7 +366,6 @@ def __check_configuration_on_add(self, configuration):
|
|||
return repository_mirror_hostnames
|
||||
|
||||
|
||||
|
||||
def add(self, configuration):
|
||||
"""Add an Updater based on the given Configuration."""
|
||||
|
||||
|
|
@ -395,7 +377,6 @@ def add(self, configuration):
|
|||
self.__repository_mirror_hostnames.update(repository_mirror_hostnames)
|
||||
|
||||
|
||||
|
||||
def refresh(self, configuration):
|
||||
"""Refresh the top-level metadata of the given Configuration."""
|
||||
|
||||
|
|
@ -419,7 +400,6 @@ def refresh(self, configuration):
|
|||
updater.refresh()
|
||||
|
||||
|
||||
|
||||
def get(self, url):
|
||||
"""Get an Updater, if any, for this URL.
|
||||
|
||||
|
|
@ -483,3 +463,18 @@ def remove(self, configuration):
|
|||
|
||||
assert isinstance(configuration, Configuration)
|
||||
|
||||
repository_mirror_hostnames = configuration.get_repository_mirror_hostnames()
|
||||
|
||||
assert configuration.hostname in self.__updaters
|
||||
assert repository_mirror_hostnames.issubset(self.__repository_mirror_hostnames)
|
||||
|
||||
# Get the updater.
|
||||
updater = self.__updaters.get(configuration.hostname)
|
||||
|
||||
# If all is well, remove the stored Updater as well as its associated
|
||||
# repository mirror hostnames.
|
||||
updater.cleanup()
|
||||
del self.__updaters[configuration.hostname]
|
||||
self.__repository_mirror_hostnames.difference_update(repository_mirror_hostnames)
|
||||
|
||||
Logger.info(UPDATER_REMOVED_MESSAGE.format(configuration=configuration))
|
||||
|
|
|
|||
Loading…
Reference in a new issue