diff options
author | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2018-09-13 15:25:56 +0100 |
---|---|---|
committer | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2018-09-14 16:38:41 +0100 |
commit | 32fad24fc02208e700891ec9867d0fd66f3242e4 (patch) | |
tree | fcff8b64a7a90a4f25e5fd190a1c039212701b09 /buildstream/_artifactcache | |
parent | 18b37aab89cc31bba16ffeb58e6560485c02d0d6 (diff) | |
download | buildstream-32fad24fc02208e700891ec9867d0fd66f3242e4.tar.gz |
artifactcache: improve _fetch_directory()
* Rename tree to dir_digest to make it clear this is a Digest object,
and not a Tree object.
* Add documentation
Diffstat (limited to 'buildstream/_artifactcache')
-rw-r--r-- | buildstream/_artifactcache/cascache.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py index 105f57c5d..9cf83a222 100644 --- a/buildstream/_artifactcache/cascache.py +++ b/buildstream/_artifactcache/cascache.py @@ -848,14 +848,26 @@ class CASCache(ArtifactCache): assert digest.size_bytes == os.fstat(stream.fileno()).st_size - def _fetch_directory(self, remote, tree): - objpath = self.objpath(tree) + # _fetch_directory(): + # + # Fetches remote directory and adds it to content addressable store. + # + # Fetches files, symbolic links and recursively other directories in + # the remote directory and adds them to the content addressable + # store. + # + # Args: + # remote (Remote): The remote to use. + # dir_digest (Digest): Digest object for the directory to fetch. + # + def _fetch_directory(self, remote, dir_digest): + objpath = self.objpath(dir_digest) if os.path.exists(objpath): # already in local cache return with tempfile.NamedTemporaryFile(dir=self.tmpdir) as out: - self._fetch_blob(remote, tree, out) + self._fetch_blob(remote, dir_digest, out) directory = remote_execution_pb2.Directory() @@ -877,10 +889,11 @@ class CASCache(ArtifactCache): for dirnode in directory.directories: self._fetch_directory(remote, dirnode.digest) - # place directory blob only in final location when we've downloaded - # all referenced blobs to avoid dangling references in the repository + # Place directory blob only in final location when we've + # downloaded all referenced blobs to avoid dangling + # references in the repository. digest = self.add_object(path=out.name) - assert digest.hash == tree.hash + assert digest.hash == dir_digest.hash def _fetch_tree(self, remote, digest): # download but do not store the Tree object |