From 320b3f2efed977bc11903e5c981a17f7a709022c Mon Sep 17 00:00:00 2001 From: Tristan Maat Date: Wed, 16 Oct 2019 17:14:15 +0100 Subject: 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. --- src/buildstream/_basecache.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/buildstream/_basecache.py') 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 -- cgit v1.2.1