diff options
author | Tristan Maat <tristan.maat@codethink.co.uk> | 2019-10-16 17:14:15 +0100 |
---|---|---|
committer | Tristan Maat <tristan.maat@codethink.co.uk> | 2019-12-03 10:45:08 +0000 |
commit | 320b3f2efed977bc11903e5c981a17f7a709022c (patch) | |
tree | 1e14355dfdd1cb0b1b37853024156c7ae5b9bd4e /src/buildstream/_basecache.py | |
parent | e660e0946ca9a6a58e4aae1d856eb14db99f3f68 (diff) | |
download | buildstream-320b3f2efed977bc11903e5c981a17f7a709022c.tar.gz |
Remove newly unused API surfaces in CASCache
This also involves a number of changes to tests and other parts of the
codebase since they were hacking about wit API that shouldn't have
existed.
Diffstat (limited to 'src/buildstream/_basecache.py')
-rw-r--r-- | src/buildstream/_basecache.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/buildstream/_basecache.py b/src/buildstream/_basecache.py index 15b1d5389..a7d06f27e 100644 --- a/src/buildstream/_basecache.py +++ b/src/buildstream/_basecache.py @@ -25,7 +25,7 @@ from . import utils from . import _yaml from ._cas import CASRemote from ._message import Message, MessageType -from ._exceptions import LoadError, RemoteError +from ._exceptions import LoadError, RemoteError, CacheError from ._remote import RemoteSpec, RemoteType @@ -429,3 +429,26 @@ class BaseCache: if not glob_expr or fnmatch(relative_path, glob_expr): # Obtain the mtime (the time a file was last modified) yield (os.path.getmtime(ref_path), relative_path) + + # _remove_ref() + # + # Removes a ref. + # + # This also takes care of pruning away directories which can + # be removed after having removed the given ref. + # + # Args: + # ref (str): The ref to remove + # basedir (str): Path of base directory the ref is in + # + # Raises: + # (CASCacheError): If the ref didnt exist, or a system error + # occurred while removing it + # + def _remove_ref(self, ref, basedir): + try: + utils._remove_path_with_parents(basedir, ref) + except FileNotFoundError as e: + raise CacheError("Could not find ref '{}'".format(ref)) from e + except OSError as e: + raise CacheError("System error while removing ref '{}': {}".format(ref, e)) from e |