Skip to content

Commit

Permalink
storage/directory.py: Move _FileType to CasBasedDirectory
Browse files Browse the repository at this point in the history
This is now entirely an internal implementation detail of how
CasBasedDirectory handles it's internal IndexEntry objects.
  • Loading branch information
gtristan committed Mar 16, 2022
1 parent a8c7d4d commit ab8a671
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
26 changes: 25 additions & 1 deletion src/buildstream/storage/_casbaseddirectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 """

Expand Down
24 changes: 0 additions & 24 deletions src/buildstream/storage/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

from .._exceptions import BstError
from ..exceptions import ErrorDomain
from ..types import FastEnum
from ..utils import BST_ARBITRARY_TIMESTAMP, FileListResult


Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions tests/internals/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit ab8a671

Please sign in to comment.