diff options
author | Shahwat Dalal <sdalal29@bloomberg.net> | 2019-06-03 14:32:54 +0100 |
---|---|---|
committer | Shahwat Dalal <sdalal29@bloomberg.net> | 2019-07-05 16:12:56 +0100 |
commit | 8e4fd46464f6043dd29a8a4862842a54e19e8821 (patch) | |
tree | 0b48f5eb0375b2d5cc00c265655d97150c0e61c8 /src/buildstream/storage | |
parent | 34763b3736029edc2ceeb8f86389b8e89441e266 (diff) | |
download | buildstream-8e4fd46464f6043dd29a8a4862842a54e19e8821.tar.gz |
utils.py: Make `magic_timestamp` a public variableshashwatdalal/make-magic-timestamp-public
Some plugin elements, such as docker-element and tar-element, require
to set `created` and/or `modified` meta-data fields. It would be nice
to use `magic_timestamp` to ensure these fields are being set in a
consistent and deterministic way.
Diffstat (limited to 'src/buildstream/storage')
-rw-r--r-- | src/buildstream/storage/_casbaseddirectory.py | 4 | ||||
-rw-r--r-- | src/buildstream/storage/_filebaseddirectory.py | 6 | ||||
-rw-r--r-- | src/buildstream/storage/directory.py | 4 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/buildstream/storage/_casbaseddirectory.py b/src/buildstream/storage/_casbaseddirectory.py index 29aee7ad3..a93f16d90 100644 --- a/src/buildstream/storage/_casbaseddirectory.py +++ b/src/buildstream/storage/_casbaseddirectory.py @@ -32,7 +32,7 @@ import os from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 from .directory import Directory, VirtualDirectoryError, _FileType from ._filebaseddirectory import FileBasedDirectory -from ..utils import FileListResult, _magic_timestamp +from ..utils import FileListResult, BST_ARBITRARY_TIMESTAMP class IndexEntry(): @@ -436,7 +436,7 @@ class CasBasedDirectory(Directory): self.cas_cache.checkout(to_directory, self._get_digest(), can_link=can_link) - def export_to_tar(self, tarfile, destination_dir, mtime=_magic_timestamp): + def export_to_tar(self, tarfile, destination_dir, mtime=BST_ARBITRARY_TIMESTAMP): raise NotImplementedError() def mark_changed(self): diff --git a/src/buildstream/storage/_filebaseddirectory.py b/src/buildstream/storage/_filebaseddirectory.py index 233b56a09..8c55819c9 100644 --- a/src/buildstream/storage/_filebaseddirectory.py +++ b/src/buildstream/storage/_filebaseddirectory.py @@ -34,7 +34,7 @@ import time from .directory import Directory, VirtualDirectoryError, _FileType from .. import utils -from ..utils import link_files, copy_files, list_relative_paths, _get_link_mtime, _magic_timestamp +from ..utils import link_files, copy_files, list_relative_paths, _get_link_mtime, BST_ARBITRARY_TIMESTAMP from ..utils import _set_deterministic_user, _set_deterministic_mtime from ..utils import FileListResult @@ -153,7 +153,7 @@ class FileBasedDirectory(Directory): # First, it sorts the results of os.listdir() to ensure the ordering of # the files in the archive is the same. Second, it sets a fixed # timestamp for each entry. See also https://bugs.python.org/issue24465. - def export_to_tar(self, tarfile, destination_dir, mtime=_magic_timestamp): + def export_to_tar(self, tarfile, destination_dir, mtime=BST_ARBITRARY_TIMESTAMP): # We need directories here, including non-empty ones, # so list_relative_paths is not used. for filename in sorted(os.listdir(self.external_directory)): @@ -187,7 +187,7 @@ class FileBasedDirectory(Directory): Return value: List(str) - list of modified paths """ return [f for f in list_relative_paths(self.external_directory) - if _get_link_mtime(os.path.join(self.external_directory, f)) != _magic_timestamp] + if _get_link_mtime(os.path.join(self.external_directory, f)) != BST_ARBITRARY_TIMESTAMP] def list_relative_paths(self): """Provide a list of all relative paths. diff --git a/src/buildstream/storage/directory.py b/src/buildstream/storage/directory.py index c40e1bdb9..c9906b058 100644 --- a/src/buildstream/storage/directory.py +++ b/src/buildstream/storage/directory.py @@ -34,7 +34,7 @@ See also: :ref:`sandboxing`. from enum import Enum from .._exceptions import BstError, ErrorDomain -from ..utils import _magic_timestamp +from ..utils import BST_ARBITRARY_TIMESTAMP class VirtualDirectoryError(BstError): @@ -122,7 +122,7 @@ class Directory(): raise NotImplementedError() - def export_to_tar(self, tarfile, destination_dir, mtime=_magic_timestamp): + def export_to_tar(self, tarfile, destination_dir, mtime=BST_ARBITRARY_TIMESTAMP): """ Exports this directory into the given tar file. Args: |