diff --git a/src/buildstream/storage/_casbaseddirectory.py b/src/buildstream/storage/_casbaseddirectory.py index ad14e1f25..570da8cef 100644 --- a/src/buildstream/storage/_casbaseddirectory.py +++ b/src/buildstream/storage/_casbaseddirectory.py @@ -34,12 +34,36 @@ from google.protobuf import timestamp_pb2 from .. import utils +from ..types import FastEnum from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 -from .directory import Directory, DirectoryError, FileMode, FileStat, _FileType +from .directory import Directory, DirectoryError, FileMode, FileStat from ._filebaseddirectory import FileBasedDirectory from ..utils import FileListResult, BST_ARBITRARY_TIMESTAMP +# _FileType: +# +# Type of file or directory entry. +# +class _FileType(FastEnum): + + # Directory + DIRECTORY = 1 + + # Regular file + REGULAR_FILE = 2 + + # Symbolic link + SYMLINK = 3 + + # Special file (FIFO, character device, block device, or socket) + SPECIAL_FILE = 4 + + def __str__(self): + # https://github.com/PyCQA/pylint/issues/2062 + return self.name.lower().replace("_", " ") # pylint: disable=no-member + + class IndexEntry: """ Directory entry used in CasBasedDirectory.index """ diff --git a/src/buildstream/storage/directory.py b/src/buildstream/storage/directory.py index 59eef7251..d59835f39 100644 --- a/src/buildstream/storage/directory.py +++ b/src/buildstream/storage/directory.py @@ -39,7 +39,6 @@ from .._exceptions import BstError from ..exceptions import ErrorDomain -from ..types import FastEnum from ..utils import BST_ARBITRARY_TIMESTAMP, FileListResult @@ -402,26 +401,3 @@ def _set_deterministic_user(self): def _create_empty_file(self, *path): with self.open_file(*path, mode="w"): pass - - -# _FileType: -# -# Type of file or directory entry. -# -class _FileType(FastEnum): - - # Directory - DIRECTORY = 1 - - # Regular file - REGULAR_FILE = 2 - - # Symbolic link - SYMLINK = 3 - - # Special file (FIFO, character device, block device, or socket) - SPECIAL_FILE = 4 - - def __str__(self): - # https://github.com/PyCQA/pylint/issues/2062 - return self.name.lower().replace("_", " ") # pylint: disable=no-member diff --git a/tests/internals/storage.py b/tests/internals/storage.py index dd0936f4b..559fcb600 100644 --- a/tests/internals/storage.py +++ b/tests/internals/storage.py @@ -11,9 +11,8 @@ from buildstream import DirectoryError from buildstream._cas import CASCache -from buildstream.storage._casbaseddirectory import CasBasedDirectory +from buildstream.storage._casbaseddirectory import CasBasedDirectory, _FileType from buildstream.storage._filebaseddirectory import FileBasedDirectory -from buildstream.storage.directory import _FileType DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "storage")